ff96faf9bd40e135edf178caab27227b14a85591
[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 final class ChoiceCaseNodeImpl extends AbstractDocumentedDataNodeContainer implements ChoiceCaseNode, DerivableSchemaNode {
27     private final QName qname;
28     private final SchemaPath path;
29     boolean augmenting;
30     boolean addedByUses;
31     ChoiceCaseNode original;
32     ConstraintDefinition constraints;
33     ImmutableSet<AugmentationSchema> augmentations;
34     ImmutableList<UnknownSchemaNode> unknownNodes;
35
36     ChoiceCaseNodeImpl(final QName qname, final SchemaPath path,final ChoiceCaseBuilder builder) {
37         super(builder);
38         this.qname = qname;
39         this.path = path;
40     }
41
42     @Override
43     public QName getQName() {
44         return qname;
45     }
46
47     @Override
48     public SchemaPath getPath() {
49         return path;
50     }
51
52     @Override
53     public boolean isConfiguration() {
54         return false;
55     }
56
57     @Override
58     public ConstraintDefinition getConstraints() {
59         return constraints;
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<ChoiceCaseNode> getOriginal() {
74         return Optional.fromNullable(original);
75     }
76
77     @Override
78     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
79         return unknownNodes;
80     }
81
82     @Override
83     public Set<AugmentationSchema> getAvailableAugmentations() {
84         return augmentations;
85     }
86
87     @Override
88     public int hashCode() {
89         final int prime = 31;
90         int result = 1;
91         result = prime * result + Objects.hashCode(qname);
92         result = prime * result + Objects.hashCode(path);
93         return result;
94     }
95
96     @Override
97     public boolean equals(final Object obj) {
98         if (this == obj) {
99             return true;
100         }
101         if (obj == null) {
102             return false;
103         }
104         if (getClass() != obj.getClass()) {
105             return false;
106         }
107         ChoiceCaseNodeImpl other = (ChoiceCaseNodeImpl) obj;
108         if (qname == null) {
109             if (other.qname != null) {
110                 return false;
111             }
112         } else if (!qname.equals(other.qname)) {
113             return false;
114         }
115         if (path == null) {
116             if (other.path != null) {
117                 return false;
118             }
119         } else if (!path.equals(other.path)) {
120             return false;
121         }
122         return true;
123     }
124
125     @Override
126     public String toString() {
127         StringBuilder sb = new StringBuilder(ChoiceCaseNodeImpl.class.getSimpleName());
128         sb.append("[");
129         sb.append("qname=");
130         sb.append(qname);
131         sb.append("]");
132         return sb.toString();
133     }
134
135 }