ab4a18b45aabc7996d6666aa8d430fabfce61158
[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 java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
17 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
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 AnyXmlSchemaNodeImpl implements AnyXmlSchemaNode, DerivableSchemaNode {
23     private final QName qname;
24     private final SchemaPath path;
25     String description;
26     String reference;
27     Status status;
28     boolean configuration;
29     AnyXmlSchemaNode original;
30     ConstraintDefinition constraintsDef;
31     boolean augmenting;
32     boolean addedByUses;
33     ImmutableList<UnknownSchemaNode> unknownNodes;
34
35     AnyXmlSchemaNodeImpl(final QName qname, final SchemaPath path) {
36         this.qname = qname;
37         this.path = path;
38     }
39
40     @Override
41     public QName getQName() {
42         return qname;
43     }
44
45     @Override
46     public SchemaPath getPath() {
47         return path;
48     }
49
50     @Override
51     public String getDescription() {
52         return description;
53     }
54
55     @Override
56     public String getReference() {
57         return reference;
58     }
59
60     @Override
61     public Status getStatus() {
62         return status;
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<AnyXmlSchemaNode> 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 constraintsDef;
88     }
89
90     @Override
91     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
92         return unknownNodes;
93     }
94
95     @Override
96     public int hashCode() {
97         final int prime = 31;
98         int result = 1;
99         result = prime * result + Objects.hashCode(qname);
100         result = prime * result + Objects.hashCode(path);
101         return result;
102     }
103
104     @Override
105     public boolean equals(final Object obj) {
106         if (this == obj) {
107             return true;
108         }
109         if (obj == null) {
110             return false;
111         }
112         if (getClass() != obj.getClass()) {
113             return false;
114         }
115         AnyXmlSchemaNodeImpl other = (AnyXmlSchemaNodeImpl) obj;
116         if (qname == null) {
117             if (other.qname != null) {
118                 return false;
119             }
120         } else if (!qname.equals(other.qname)) {
121             return false;
122         }
123         if (path == null) {
124             if (other.path != null) {
125                 return false;
126             }
127         } else if (!path.equals(other.path)) {
128             return false;
129         }
130         return true;
131     }
132
133     @Override
134     public String toString() {
135         StringBuilder sb = new StringBuilder(AnyXmlSchemaNodeImpl.class.getSimpleName());
136         sb.append("[");
137         sb.append("qname=").append(qname);
138         sb.append(", path=").append(path);
139         sb.append("]");
140         return sb.toString();
141     }
142
143 }