Merge "Migrate ClassLoaderUtils callers"
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / ListSchemaNodeImpl.java
1 package org.opendaylight.yangtools.yang.parser.builder.impl;
2
3 import com.google.common.base.Optional;
4 import com.google.common.collect.ImmutableList;
5 import com.google.common.collect.ImmutableSet;
6 import java.util.List;
7 import java.util.Set;
8 import org.opendaylight.yangtools.yang.common.QName;
9 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
10 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
11 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
12 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
14 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
15 import org.opendaylight.yangtools.yang.parser.builder.util.AbstractDocumentedDataNodeContainer;
16
17 final class ListSchemaNodeImpl extends AbstractDocumentedDataNodeContainer implements
18         ListSchemaNode, DerivableSchemaNode {
19     private final QName qname;
20     private final SchemaPath path;
21     ImmutableList<QName> keyDefinition;
22     boolean augmenting;
23     boolean addedByUses;
24     ListSchemaNode original;
25     boolean configuration;
26     ConstraintDefinition constraints;
27     ImmutableSet<AugmentationSchema> augmentations;
28     ImmutableList<UnknownSchemaNode> unknownNodes;
29     boolean userOrdered;
30
31     ListSchemaNodeImpl(final QName qname, final SchemaPath path, final ListSchemaNodeBuilder builder) {
32         super(builder);
33         this.qname = qname;
34         this.path = path;
35     }
36
37     @Override
38     public QName getQName() {
39         return qname;
40     }
41
42     @Override
43     public SchemaPath getPath() {
44         return path;
45     }
46
47     @Override
48     public List<QName> getKeyDefinition() {
49         return keyDefinition;
50     }
51
52     @Override
53     public boolean isAugmenting() {
54         return augmenting;
55     }
56
57     @Override
58     public boolean isAddedByUses() {
59         return addedByUses;
60     }
61
62     @Override
63     public Optional<ListSchemaNode> getOriginal() {
64         return Optional.fromNullable(original);
65     }
66
67     @Override
68     public boolean isConfiguration() {
69         return configuration;
70     }
71
72     @Override
73     public ConstraintDefinition getConstraints() {
74         return constraints;
75     }
76
77     @Override
78     public Set<AugmentationSchema> getAvailableAugmentations() {
79         return augmentations;
80     }
81
82     @Override
83     public boolean isUserOrdered() {
84         return userOrdered;
85     }
86
87     @Override
88     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
89         return unknownNodes;
90     }
91
92     @Override
93     public int hashCode() {
94         final int prime = 31;
95         int result = 1;
96         result = prime * result + ((qname == null) ? 0 : qname.hashCode());
97         result = prime * result + ((path == null) ? 0 : path.hashCode());
98         return result;
99     }
100
101     @Override
102     public boolean equals(final Object obj) {
103         if (this == obj) {
104             return true;
105         }
106         if (obj == null) {
107             return false;
108         }
109         if (getClass() != obj.getClass()) {
110             return false;
111         }
112         final ListSchemaNodeImpl other = (ListSchemaNodeImpl) obj;
113         if (qname == null) {
114             if (other.qname != null) {
115                 return false;
116             }
117         } else if (!qname.equals(other.qname)) {
118             return false;
119         }
120         if (path == null) {
121             if (other.path != null) {
122                 return false;
123             }
124         } else if (!path.equals(other.path)) {
125             return false;
126         }
127         return true;
128     }
129
130     @Override
131     public String toString() {
132         return "list " + qname.getLocalName();
133     }
134 }