63d9141f3fa7ef27a2ff6b6dd5a3a80463057766
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / LeafListSchemaNodeImpl.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 java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
16 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22
23 final class LeafListSchemaNodeImpl implements LeafListSchemaNode, DerivableSchemaNode {
24     private final QName qname;
25     private final SchemaPath path;
26     String description;
27     String reference;
28     Status status;
29     boolean augmenting;
30     boolean addedByUses;
31     LeafListSchemaNode original;
32     boolean configuration;
33     ConstraintDefinition constraintsDef;
34     TypeDefinition<?> type;
35     boolean userOrdered;
36     ImmutableList<UnknownSchemaNode> unknownNodes;
37
38     LeafListSchemaNodeImpl(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<LeafListSchemaNode> 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 boolean isUserOrdered() {
100         return userOrdered;
101     }
102
103     @Override
104     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
105         return unknownNodes;
106     }
107
108     @Override
109     public int hashCode() {
110         final int prime = 31;
111         int result = 1;
112         result = prime * result + Objects.hashCode(qname);
113         result = prime * result + Objects.hashCode(path);
114         return result;
115     }
116
117     @Override
118     public boolean equals(final Object obj) {
119         if (this == obj) {
120             return true;
121         }
122         if (obj == null) {
123             return false;
124         }
125         if (getClass() != obj.getClass()) {
126             return false;
127         }
128         LeafListSchemaNodeImpl other = (LeafListSchemaNodeImpl) obj;
129         if (qname == null) {
130             if (other.qname != null) {
131                 return false;
132             }
133         } else if (!qname.equals(other.qname)) {
134             return false;
135         }
136         if (path == null) {
137             if (other.path != null) {
138                 return false;
139             }
140         } else if (!path.equals(other.path)) {
141             return false;
142         }
143         return true;
144     }
145
146     @Override
147     public String toString() {
148         StringBuilder sb = new StringBuilder(LeafListSchemaNodeImpl.class.getSimpleName());
149         sb.append("[");
150         sb.append(qname);
151         sb.append("]");
152         return sb.toString();
153     }
154 }