Merge "Migrate ClassLoaderUtils callers"
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / LeafSchemaNodeImpl.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.base.Optional;
11 import com.google.common.collect.ImmutableList;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
15 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21
22 final class LeafSchemaNodeImpl implements LeafSchemaNode, DerivableSchemaNode {
23     private final QName qname;
24     private final SchemaPath path;
25     String description;
26     String reference;
27     Status status;
28     boolean augmenting;
29     boolean addedByUses;
30     LeafSchemaNode original;
31     boolean configuration;
32     ConstraintDefinition constraintsDef;
33     TypeDefinition<?> type;
34     ImmutableList<UnknownSchemaNode> unknownNodes;
35     String defaultStr;
36     String unitsStr;
37
38     LeafSchemaNodeImpl(final QName qname, final SchemaPath path) {
39         this.qname = qname;
40         this.path = path;
41     }
42
43     @Override
44     public QName getQName() {
45         return qname;
46     }
47
48     @Override
49     public SchemaPath getPath() {
50         return path;
51     }
52
53     @Override
54     public String getDescription() {
55         return description;
56     }
57
58     @Override
59     public String getReference() {
60         return reference;
61     }
62
63     @Override
64     public Status getStatus() {
65         return status;
66     }
67
68     @Override
69     public boolean isAugmenting() {
70         return augmenting;
71     }
72
73     @Override
74     public boolean isAddedByUses() {
75         return addedByUses;
76     }
77
78     @Override
79     public Optional<LeafSchemaNode> getOriginal() {
80         return Optional.fromNullable(original);
81     }
82
83     @Override
84     public boolean isConfiguration() {
85         return configuration;
86     }
87
88     @Override
89     public ConstraintDefinition getConstraints() {
90         return constraintsDef;
91     }
92
93     @Override
94     public TypeDefinition<?> getType() {
95         return type;
96     }
97
98     @Override
99     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
100         return unknownNodes;
101     }
102
103     @Override
104     public String getDefault() {
105         return defaultStr;
106     }
107
108     @Override
109     public String getUnits() {
110         return unitsStr;
111     }
112
113     @Override
114     public int hashCode() {
115         final int prime = 31;
116         int result = 1;
117         result = prime * result + ((qname == null) ? 0 : qname.hashCode());
118         result = prime * result + ((path == null) ? 0 : path.hashCode());
119         return result;
120     }
121
122     @Override
123     public boolean equals(final Object obj) {
124         if (this == obj) {
125             return true;
126         }
127         if (obj == null) {
128             return false;
129         }
130         if (getClass() != obj.getClass()) {
131             return false;
132         }
133         LeafSchemaNodeImpl other = (LeafSchemaNodeImpl) obj;
134         if (qname == null) {
135             if (other.qname != null) {
136                 return false;
137             }
138         } else if (!qname.equals(other.qname)) {
139             return false;
140         }
141         if (path == null) {
142             if (other.path != null) {
143                 return false;
144             }
145         } else if (!path.equals(other.path)) {
146             return false;
147         }
148         return true;
149     }
150
151     @Override
152     public String toString() {
153         StringBuilder sb = new StringBuilder(LeafSchemaNodeImpl.class.getSimpleName());
154         sb.append("[");
155         sb.append("qname=").append(qname);
156         sb.append(", path=").append(path);
157         sb.append("]");
158         return sb.toString();
159     }
160 }