2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
24 import com.fasterxml.jackson.annotation.JsonIgnore;
25 import java.util.ArrayList;
26 import java.util.List;
27 import org.opendaylight.yangtools.yang.common.QName;
29 public class SchemaInfo {
30 private String namespace;
31 private String revision;
32 private List<String> notification;
34 public SchemaInfo() {}
38 public SchemaInfo(QName qname) {
39 this.namespace = qname.getNamespace().toString();
40 this.revision = qname.getRevision().isPresent() ? qname.getRevision().get().toString() : null;
41 this.notification = new ArrayList<>();
42 this.notification.add(qname.getLocalName());
45 public String getNamespace() {
49 public void setNamespace(String namespace) {
50 this.namespace = namespace;
53 public String getRevision() {
57 public void setRevision(String revision) {
58 this.revision = revision;
61 public List<String> getNotification() {
65 public void setNotification(List<String> notification) {
66 this.notification = notification;
70 public boolean isValid() {
71 return this.namespace != null
72 && (this.notification == null || (this.notification != null && this.notification.size() > 0));
76 * Check if schema(qname based info of notification) matches into this scope
81 public boolean matches(ReducedSchemaInfo schema) {
82 //if namespace is * placeholder => true
83 if (this.namespace.equals("*")) {
86 //if namespace does not match => false
87 if (!this.namespace.equals(schema.getNamespace().toString())) {
90 //if revision of scope is set and it does not match => false
91 if (this.revision != null && !this.revision.equals(schema.getRevision())){
94 //if notification of scope is set and is current notification is not in the list
95 if (this.notification != null && !this.notification.contains(schema.getType())) {
102 public boolean equalsNamespaceAndRevision(QName qname) {
103 if (this.namespace == null) {
106 if (!this.namespace.equals(qname.getNamespace().toString())) {
109 if (this.revision == null && qname.getRevision().isEmpty()) {
112 if (this.revision != null) {
113 return this.revision.equals(qname.getRevision().isEmpty() ? null : qname.getRevision().get().toString());
119 public void addNotification(String notification) {
120 if(this.notification ==null) {
121 this.notification = new ArrayList<>();
123 this.notification.add(notification);
127 public String toString() {
128 return "SchemaInfo [namespace=" + namespace + ", revision=" + revision + ", notification=" + notification + "]";