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