9bc51d4c5c2f932e0d2e24d61c51cf52891509b6
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : ccsdk features
4  * ================================================================================
5  * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
6  * All rights reserved.
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
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  */
22 package org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.data;
23
24 import java.util.Optional;
25 import org.opendaylight.yangtools.yang.common.QName;
26 import org.opendaylight.yangtools.yang.common.Revision;
27
28 public class ReducedSchemaInfo {
29     private String namespace;
30     private String revision;
31     private String type;
32
33     public ReducedSchemaInfo() {}
34
35
36
37     public ReducedSchemaInfo(QName qname) {
38         this.namespace = qname.getNamespace().toString();
39         Optional<Revision> orev = qname.getRevision();
40         this.revision = orev.isPresent() ? orev.get().toString() : null;
41         this.type = qname.getLocalName();
42     }
43
44     public boolean equals(QName obj) {
45         Optional<Revision> orev = obj.getRevision();
46         if (this.namespace.equals(obj.getNamespace().toString()) && this.type.equals(obj.getLocalName())) {
47             if (this.revision == null) {
48                 return orev.isEmpty();
49             } else if (orev.isEmpty()) {
50                 return false;
51             } else {
52                 return orev.get().toString().equals(this.revision);
53             }
54         }
55         return false;
56     }
57
58     public String getNamespace() {
59         return namespace;
60     }
61
62     public void setNamespace(String namespace) {
63         this.namespace = namespace;
64     }
65
66     public String getRevision() {
67         return revision;
68     }
69
70     public void setRevision(String revision) {
71         this.revision = revision;
72     }
73
74     public String getType() {
75         return type;
76     }
77
78     public void setType(String type) {
79         this.type = type;
80     }
81
82
83 }