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