Test for class RefineHolder.java
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / api / AbstractSchemaNodeBuilder.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.yangtools.yang.parser.builder.api;\r
9 \r
10 import java.util.List;\r
11 \r
12 import org.opendaylight.yangtools.yang.common.QName;\r
13 import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
14 import org.opendaylight.yangtools.yang.model.api.Status;\r
15 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;\r
16 \r
17 /**\r
18  * Basic implementation of SchemaNodeBuilder.\r
19  */\r
20 public abstract class AbstractSchemaNodeBuilder extends AbstractBuilder implements SchemaNodeBuilder {\r
21     protected QName qname;\r
22     protected SchemaPath schemaPath;\r
23     protected String description;\r
24     protected String reference;\r
25     protected Status status = Status.CURRENT;\r
26     protected List<UnknownSchemaNode> unknownNodes;\r
27 \r
28     protected AbstractSchemaNodeBuilder(final String moduleName, final int line, final QName qname) {\r
29         super(moduleName, line);\r
30         this.qname = qname;\r
31     }\r
32 \r
33     @Override\r
34     public int hashCode() {\r
35         final int prime = 31;\r
36         int result = super.hashCode();\r
37         result = prime * result + ((parent == null) ? 0 : parent.hashCode());\r
38         result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());\r
39         return result;\r
40     }\r
41 \r
42     @Override\r
43     public boolean equals(Object obj) {\r
44         if (this == obj) {\r
45             return true;\r
46         }\r
47         if (obj == null) {\r
48             return false;\r
49         }\r
50         if (getClass() != obj.getClass()) {\r
51             return false;\r
52         }\r
53         if (!super.equals(obj)) {\r
54             return false;\r
55         }\r
56         AbstractSchemaNodeBuilder other = (AbstractSchemaNodeBuilder) obj;\r
57         if (parent == null) {\r
58             if (other.parent != null) {\r
59                 return false;\r
60             }\r
61         } else if (!parent.equals(other.parent)) {\r
62             return false;\r
63         }\r
64         if (schemaPath == null) {\r
65             if (other.schemaPath != null) {\r
66                 return false;\r
67             }\r
68         } else if (!schemaPath.equals(other.schemaPath)) {\r
69             return false;\r
70         }\r
71         return true;\r
72     }\r
73 \r
74     public QName getQName() {\r
75         return qname;\r
76     }\r
77 \r
78     @Override\r
79     public SchemaPath getPath() {\r
80         return schemaPath;\r
81     }\r
82 \r
83     @Override\r
84     public void setPath(SchemaPath schemaPath) {\r
85         this.schemaPath = schemaPath;\r
86     }\r
87 \r
88     @Override\r
89     public String getDescription() {\r
90         return description;\r
91     }\r
92 \r
93     @Override\r
94     public void setDescription(String description) {\r
95         this.description = description;\r
96     }\r
97 \r
98     @Override\r
99     public String getReference() {\r
100         return reference;\r
101     }\r
102 \r
103     @Override\r
104     public void setReference(String reference) {\r
105         this.reference = reference;\r
106     }\r
107 \r
108     @Override\r
109     public Status getStatus() {\r
110         return status;\r
111     }\r
112 \r
113     @Override\r
114     public void setStatus(Status status) {\r
115         if (status != null) {\r
116             this.status = status;\r
117         }\r
118     }\r
119 \r
120     public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {\r
121         this.unknownNodes = unknownNodes;\r
122     }\r
123 \r
124 }\r