2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.yangtools.yang.parser.builder.impl;
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;
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.ChoiceSchemaNode;
21 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
22 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 import org.opendaylight.yangtools.yang.model.api.Status;
25 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
28 * @deprecated Pre-Beryllium implementation, scheduled for removal.
31 final class ChoiceSchemaNodeImpl implements ChoiceSchemaNode, DerivableSchemaNode {
32 private final QName qname;
33 private final SchemaPath path;
39 ChoiceSchemaNode original;
40 boolean configuration;
41 ConstraintDefinition constraints;
42 ImmutableSet<ChoiceCaseNode> cases;
43 ImmutableSet<AugmentationSchema> augmentations;
44 ImmutableList<UnknownSchemaNode> unknownNodes;
47 ChoiceSchemaNodeImpl(final QName qname, final SchemaPath path) {
53 public QName getQName() {
58 public SchemaPath getPath() {
63 public String getDescription() {
68 public String getReference() {
73 public Status getStatus() {
78 public boolean isAugmenting() {
83 public boolean isAddedByUses() {
88 public Optional<ChoiceSchemaNode> getOriginal() {
89 return Optional.fromNullable(original);
93 public boolean isConfiguration() {
98 public ConstraintDefinition getConstraints() {
103 public Set<AugmentationSchema> getAvailableAugmentations() {
104 return augmentations;
108 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
113 public Set<ChoiceCaseNode> getCases() {
118 public ChoiceCaseNode getCaseNodeByName(final QName name) {
120 throw new IllegalArgumentException("Choice Case QName cannot be NULL!");
122 for (final ChoiceCaseNode caseNode : cases) {
123 if (caseNode != null && name.equals(caseNode.getQName())) {
131 public ChoiceCaseNode getCaseNodeByName(final String name) {
133 throw new IllegalArgumentException("Choice Case string Name cannot be NULL!");
135 for (final ChoiceCaseNode caseNode : cases) {
136 if (caseNode != null && (caseNode.getQName() != null)
137 && name.equals(caseNode.getQName().getLocalName())) {
145 public String getDefaultCase() {
150 public int hashCode() {
151 final int prime = 31;
153 result = prime * result + Objects.hashCode(qname);
154 result = prime * result + Objects.hashCode(path);
159 public boolean equals(final Object obj) {
166 if (getClass() != obj.getClass()) {
169 ChoiceSchemaNodeImpl other = (ChoiceSchemaNodeImpl) obj;
171 if (other.qname != null) {
174 } else if (!qname.equals(other.qname)) {
178 if (other.path != null) {
181 } else if (!path.equals(other.path)) {
188 public String toString() {
189 return ChoiceSchemaNodeImpl.class.getSimpleName() + "[" +