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