Merge "Migrate ClassLoaderUtils callers"
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / AnyXmlSchemaNodeImpl.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.yangtools.yang.parser.builder.impl;
9
10 import com.google.common.base.Optional;
11 import com.google.common.collect.ImmutableList;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
16 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
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 AnyXmlSchemaNodeImpl implements AnyXmlSchemaNode, DerivableSchemaNode {
22     private final QName qname;
23     private final SchemaPath path;
24     String description;
25     String reference;
26     Status status;
27     boolean configuration;
28     AnyXmlSchemaNode original;
29     ConstraintDefinition constraintsDef;
30     boolean augmenting;
31     boolean addedByUses;
32     ImmutableList<UnknownSchemaNode> unknownNodes;
33
34     AnyXmlSchemaNodeImpl(final QName qname, final SchemaPath path) {
35         this.qname = qname;
36         this.path = path;
37     }
38
39     @Override
40     public QName getQName() {
41         return qname;
42     }
43
44     @Override
45     public SchemaPath getPath() {
46         return path;
47     }
48
49     @Override
50     public String getDescription() {
51         return description;
52     }
53
54     @Override
55     public String getReference() {
56         return reference;
57     }
58
59     @Override
60     public Status getStatus() {
61         return status;
62     }
63
64     @Override
65     public boolean isAugmenting() {
66         return augmenting;
67     }
68
69     @Override
70     public boolean isAddedByUses() {
71         return addedByUses;
72     }
73
74     @Override
75     public Optional<AnyXmlSchemaNode> getOriginal() {
76         return Optional.fromNullable(original);
77     }
78
79     @Override
80     public boolean isConfiguration() {
81         return configuration;
82     }
83
84     @Override
85     public ConstraintDefinition getConstraints() {
86         return constraintsDef;
87     }
88
89     @Override
90     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
91         return unknownNodes;
92     }
93
94     @Override
95     public int hashCode() {
96         final int prime = 31;
97         int result = 1;
98         result = prime * result + ((qname == null) ? 0 : qname.hashCode());
99         result = prime * result + ((path == null) ? 0 : path.hashCode());
100         return result;
101     }
102
103     @Override
104     public boolean equals(final Object obj) {
105         if (this == obj) {
106             return true;
107         }
108         if (obj == null) {
109             return false;
110         }
111         if (getClass() != obj.getClass()) {
112             return false;
113         }
114         AnyXmlSchemaNodeImpl other = (AnyXmlSchemaNodeImpl) obj;
115         if (qname == null) {
116             if (other.qname != null) {
117                 return false;
118             }
119         } else if (!qname.equals(other.qname)) {
120             return false;
121         }
122         if (path == null) {
123             if (other.path != null) {
124                 return false;
125             }
126         } else if (!path.equals(other.path)) {
127             return false;
128         }
129         return true;
130     }
131
132     @Override
133     public String toString() {
134         StringBuilder sb = new StringBuilder(AnyXmlSchemaNodeImpl.class.getSimpleName());
135         sb.append("[");
136         sb.append("qname=").append(qname);
137         sb.append(", path=").append(path);
138         sb.append("]");
139         return sb.toString();
140     }
141
142 }