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