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