Use String concatenation instead of StringBuffer/Builder
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / UnknownSchemaNodeImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.parser.builder.impl;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18
19 /**
20  * @deprecated Pre-Beryllium implementation, scheduled for removal.
21  */
22 @Deprecated
23 final class UnknownSchemaNodeImpl implements UnknownSchemaNode {
24     private final QName qname;
25     private final SchemaPath path;
26     private ExtensionDefinition extension;
27     String description;
28     String reference;
29     Status status = Status.CURRENT;
30     private List<UnknownSchemaNode> unknownNodes = ImmutableList.of();
31     private QName nodeType;
32     private String nodeParameter;
33     boolean addedByUses;
34
35     UnknownSchemaNodeImpl(final QName qname, final SchemaPath path) {
36         this.qname = qname;
37         this.path = path;
38     }
39
40     @Override
41     public QName getQName() {
42         return qname;
43     }
44
45     @Override
46     public SchemaPath getPath() {
47         return path;
48     }
49
50     @Override
51     public ExtensionDefinition getExtensionDefinition() {
52         return extension;
53     }
54
55     void setExtensionDefinition(final ExtensionDefinition extension) {
56         this.extension = extension;
57     }
58
59     @Override
60     public String getDescription() {
61         return description;
62     }
63
64     @Override
65     public String getReference() {
66         return reference;
67     }
68
69     @Override
70     public Status getStatus() {
71         return status;
72     }
73
74     @Override
75     public boolean isAddedByUses() {
76         return addedByUses;
77     }
78
79     @Override
80     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
81         return unknownNodes;
82     }
83
84     void setUnknownSchemaNodes(final List<UnknownSchemaNode> unknownNodes) {
85         if (unknownNodes != null) {
86             this.unknownNodes = ImmutableList.copyOf(unknownNodes);
87         }
88     }
89
90     @Override
91     public QName getNodeType() {
92         return nodeType;
93     }
94
95     void setNodeType(final QName nodeType) {
96         this.nodeType = nodeType;
97     }
98
99     @Override
100     public String getNodeParameter() {
101         return nodeParameter;
102     }
103
104     void setNodeParameter(final String nodeParameter) {
105         this.nodeParameter = nodeParameter;
106     }
107
108     @Override
109     public String toString() {
110         return String.valueOf(nodeType.getNamespace()) +
111                 ":" +
112                 nodeType.getLocalName() +
113                 " " +
114                 nodeParameter;
115     }
116
117     @Override
118     public int hashCode() {
119         final int prime = 31;
120         int result = 1;
121         result = prime * result + Objects.hashCode(qname);
122         result = prime * result + Objects.hashCode(path);
123         result = prime * result + Objects.hashCode(nodeType);
124         result = prime * result + Objects.hashCode(nodeParameter);
125         return result;
126     }
127
128     @Override
129     public boolean equals(final Object obj) {
130         if (this == obj) {
131             return true;
132         }
133         if (obj == null) {
134             return false;
135         }
136         if (getClass() != obj.getClass()) {
137             return false;
138         }
139         UnknownSchemaNodeImpl other = (UnknownSchemaNodeImpl) obj;
140         if (qname == null) {
141             if (other.qname != null) {
142                 return false;
143             }
144         } else if (!qname.equals(other.qname)) {
145             return false;
146         }
147         if (path == null) {
148             if (other.path != null) {
149                 return false;
150             }
151         } else if (!path.equals(other.path)) {
152             return false;
153         }
154         if (nodeType == null) {
155             if (other.nodeType != null) {
156                 return false;
157             }
158         } else if (!nodeType.equals(other.nodeType)) {
159             return false;
160         }
161         if (nodeParameter == null) {
162             if (other.nodeParameter != null) {
163                 return false;
164             }
165         } else if (!nodeParameter.equals(other.nodeParameter)) {
166             return false;
167         }
168         return true;
169     }
170
171     @Override
172     public boolean isAddedByAugmentation() {
173         return false;
174     }
175 }