625d30959549a4fb631d59938bb0e583e710de39
[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 final class IdentitySchemaNodeImpl implements IdentitySchemaNode {
23     private final QName qname;
24     private final SchemaPath path;
25     IdentitySchemaNode baseIdentity;
26     private final Set<IdentitySchemaNode> derivedIdentities;
27     String description;
28     String reference;
29     Status status;
30     ImmutableList<UnknownSchemaNode> unknownNodes;
31
32     IdentitySchemaNodeImpl(final QName qname, final SchemaPath path,
33             final Set<IdentitySchemaNode> derivedIdentities) {
34         this.qname = qname;
35         this.path = path;
36         this.derivedIdentities = derivedIdentities;
37     }
38
39     @Override
40     public QName getQName() {
41         return qname;
42     }
43
44     @Override
45     public IdentitySchemaNode getBaseIdentity() {
46         return baseIdentity;
47     }
48
49     @Override
50     public Set<IdentitySchemaNode> getDerivedIdentities() {
51         return Collections.unmodifiableSet(derivedIdentities);
52     }
53
54     @Override
55     public String getDescription() {
56         return description;
57     }
58
59     @Override
60     public String getReference() {
61         return reference;
62     }
63
64     @Override
65     public Status getStatus() {
66         return status;
67     }
68
69     @Override
70     public SchemaPath getPath() {
71         return path;
72     }
73
74     @Override
75     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
76         return unknownNodes;
77     }
78
79     @Override
80     public int hashCode() {
81         final int prime = 31;
82         int result = 1;
83         result = prime * result + Objects.hashCode(qname);
84         result = prime * result + Objects.hashCode(path);
85         return result;
86     }
87
88     @Override
89     public boolean equals(final Object obj) {
90         if (this == obj) {
91             return true;
92         }
93         if (obj == null) {
94             return false;
95         }
96         if (getClass() != obj.getClass()) {
97             return false;
98         }
99         IdentitySchemaNodeImpl other = (IdentitySchemaNodeImpl) obj;
100         if (qname == null) {
101             if (other.qname != null) {
102                 return false;
103             }
104         } else if (!qname.equals(other.qname)) {
105             return false;
106         }
107         if (path == null) {
108             if (other.path != null) {
109                 return false;
110             }
111         } else if (!path.equals(other.path)) {
112             return false;
113         }
114         return true;
115     }
116
117     @Override
118     public String toString() {
119         StringBuilder sb = new StringBuilder(IdentitySchemaNodeImpl.class.getSimpleName());
120         sb.append("[");
121         sb.append("base=").append(baseIdentity);
122         sb.append(", qname=").append(qname);
123         sb.append("]");
124         return sb.toString();
125     }
126 }