BUG-865: deprecate pre-Beryllium parser elements
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / IdentitySchemaNodeImpl.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.collect.ImmutableList;
12 import java.util.Collections;
13 import java.util.List;
14 import java.util.Objects;
15 import java.util.Set;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21
22 /**
23  * @deprecated Pre-Beryllium implementation, scheduled for removal.
24  */
25 @Deprecated
26 final class IdentitySchemaNodeImpl implements IdentitySchemaNode {
27     private final QName qname;
28     private final SchemaPath path;
29     IdentitySchemaNode baseIdentity;
30     private final Set<IdentitySchemaNode> derivedIdentities;
31     String description;
32     String reference;
33     Status status;
34     ImmutableList<UnknownSchemaNode> unknownNodes;
35
36     IdentitySchemaNodeImpl(final QName qname, final SchemaPath path,
37             final Set<IdentitySchemaNode> derivedIdentities) {
38         this.qname = qname;
39         this.path = path;
40         this.derivedIdentities = derivedIdentities;
41     }
42
43     @Override
44     public QName getQName() {
45         return qname;
46     }
47
48     @Override
49     public IdentitySchemaNode getBaseIdentity() {
50         return baseIdentity;
51     }
52
53     @Override
54     public Set<IdentitySchemaNode> getDerivedIdentities() {
55         return Collections.unmodifiableSet(derivedIdentities);
56     }
57
58     @Override
59     public String getDescription() {
60         return description;
61     }
62
63     @Override
64     public String getReference() {
65         return reference;
66     }
67
68     @Override
69     public Status getStatus() {
70         return status;
71     }
72
73     @Override
74     public SchemaPath getPath() {
75         return path;
76     }
77
78     @Override
79     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
80         return unknownNodes;
81     }
82
83     @Override
84     public int hashCode() {
85         final int prime = 31;
86         int result = 1;
87         result = prime * result + Objects.hashCode(qname);
88         result = prime * result + Objects.hashCode(path);
89         return result;
90     }
91
92     @Override
93     public boolean equals(final Object obj) {
94         if (this == obj) {
95             return true;
96         }
97         if (obj == null) {
98             return false;
99         }
100         if (getClass() != obj.getClass()) {
101             return false;
102         }
103         IdentitySchemaNodeImpl other = (IdentitySchemaNodeImpl) obj;
104         if (qname == null) {
105             if (other.qname != null) {
106                 return false;
107             }
108         } else if (!qname.equals(other.qname)) {
109             return false;
110         }
111         if (path == null) {
112             if (other.path != null) {
113                 return false;
114             }
115         } else if (!path.equals(other.path)) {
116             return false;
117         }
118         return true;
119     }
120
121     @Override
122     public String toString() {
123         StringBuilder sb = new StringBuilder(IdentitySchemaNodeImpl.class.getSimpleName());
124         sb.append("[");
125         sb.append("base=").append(baseIdentity);
126         sb.append(", qname=").append(qname);
127         sb.append("]");
128         return sb.toString();
129     }
130 }