Implemented refine statement parsing.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / model / parser / util / BitImpl.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.controller.yang.model.parser.util;
9
10 import java.util.Collections;
11 import java.util.List;
12
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
18 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition.Bit;
19
20 public final class BitImpl implements BitsTypeDefinition.Bit {
21     private final Long position;
22     private final QName qname;
23     private final SchemaPath schemaPath;
24     private final String description;
25     private final String reference;
26     private final Status status;
27     private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
28
29     BitImpl(final Long position, final QName qname,
30             final SchemaPath schemaPath, final String description,
31             final String reference, final Status status,
32             final List<UnknownSchemaNode> unknownNodes) {
33         this.position = position;
34         this.qname = qname;
35         this.schemaPath = schemaPath;
36         this.description = description;
37         this.reference = reference;
38         this.status = status;
39         if(unknownNodes != null) {
40             this.unknownNodes = unknownNodes;
41         }
42     }
43
44     @Override
45     public QName getQName() {
46         return qname;
47     }
48
49     @Override
50     public SchemaPath getPath() {
51         return schemaPath;
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 List<UnknownSchemaNode> getUnknownSchemaNodes() {
71         return unknownNodes;
72     }
73
74     @Override
75     public Long getPosition() {
76         return position;
77     }
78
79     @Override
80     public String getName() {
81         return qname.getLocalName();
82     }
83
84     @Override
85     public int hashCode() {
86         final int prime = 31;
87         int result = 1;
88         result = prime * result
89                 + ((qname == null) ? 0 : qname.hashCode());
90         result = prime * result
91                 + ((schemaPath == null) ? 0 : schemaPath.hashCode());
92         result = prime * result
93                 + ((position == null) ? 0 : position.hashCode());
94         result = prime
95                 * result
96                 + ((unknownNodes == null) ? 0 : unknownNodes.hashCode());
97         return result;
98     }
99
100     @Override
101     public boolean equals(Object obj) {
102         if (this == obj) {
103             return true;
104         }
105         if (obj == null) {
106             return false;
107         }
108         if (getClass() != obj.getClass()) {
109             return false;
110         }
111         Bit other = (Bit) obj;
112         if (qname == null) {
113             if (other.getQName() != null) {
114                 return false;
115             }
116         } else if (!qname.equals(other.getQName())) {
117             return false;
118         }
119         if (schemaPath == null) {
120             if (other.getPath() != null) {
121                 return false;
122             }
123         } else if (!schemaPath.equals(other.getPath())) {
124             return false;
125         }
126         return true;
127     }
128
129     @Override
130     public String toString() {
131         return Bit.class.getSimpleName() + "[name="
132                 + qname.getLocalName() + ", position=" + position + "]";
133     }
134
135 }