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