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