Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / model / util / Leafref.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.controller.model.util;\r
9 \r
10 import java.util.Collections;\r
11 import java.util.List;\r
12 \r
13 import org.opendaylight.controller.model.api.type.LeafrefTypeDefinition;\r
14 import org.opendaylight.controller.yang.common.QName;\r
15 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
16 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
17 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
18 import org.opendaylight.controller.yang.model.api.Status;\r
19 \r
20 public class Leafref implements LeafrefTypeDefinition {\r
21     private static final QName name = BaseTypes.constructQName("leafref");\r
22     private static final String description = "";\r
23     private static final String reference = "";\r
24     private final SchemaPath path = BaseTypes.schemaPath(name);\r
25     private final RevisionAwareXPath xpath;\r
26     private final String units = "";\r
27 \r
28     public Leafref(RevisionAwareXPath xpath) {\r
29         super();\r
30         this.xpath = xpath;\r
31     }\r
32 \r
33     /*\r
34      * (non-Javadoc)\r
35      * \r
36      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
37      */\r
38     @Override\r
39     public LeafrefTypeDefinition getBaseType() {\r
40         return this;\r
41     }\r
42 \r
43     /*\r
44      * (non-Javadoc)\r
45      * \r
46      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
47      */\r
48     @Override\r
49     public String getUnits() {\r
50         return units;\r
51     }\r
52 \r
53     /*\r
54      * (non-Javadoc)\r
55      * \r
56      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
57      */\r
58     @Override\r
59     public Object getDefaultValue() {\r
60         return this;\r
61     }\r
62 \r
63     /*\r
64      * (non-Javadoc)\r
65      * \r
66      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
67      */\r
68     @Override\r
69     public QName getQName() {\r
70         return name;\r
71     }\r
72 \r
73     /*\r
74      * (non-Javadoc)\r
75      * \r
76      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
77      */\r
78     @Override\r
79     public SchemaPath getPath() {\r
80         return path;\r
81     }\r
82 \r
83     /*\r
84      * (non-Javadoc)\r
85      * \r
86      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
87      */\r
88     @Override\r
89     public String getDescription() {\r
90         return description;\r
91     }\r
92 \r
93     /*\r
94      * (non-Javadoc)\r
95      * \r
96      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
97      */\r
98     @Override\r
99     public String getReference() {\r
100         return reference;\r
101     }\r
102 \r
103     /*\r
104      * (non-Javadoc)\r
105      * \r
106      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
107      */\r
108     @Override\r
109     public Status getStatus() {\r
110         return Status.CURRENT;\r
111     }\r
112 \r
113     /*\r
114      * (non-Javadoc)\r
115      * \r
116      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()\r
117      */\r
118     @Override\r
119     public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
120         return Collections.emptyList();\r
121     }\r
122 \r
123     /*\r
124      * (non-Javadoc)\r
125      * \r
126      * @see\r
127      * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition#getPathStatement()\r
128      */\r
129     @Override\r
130     public RevisionAwareXPath getPathStatement() {\r
131         return xpath;\r
132     }\r
133 \r
134     @Override\r
135     public int hashCode() {\r
136         final int prime = 31;\r
137         int result = 1;\r
138         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
139         result = prime * result + ((units == null) ? 0 : units.hashCode());\r
140         result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());\r
141         return result;\r
142     }\r
143 \r
144     @Override\r
145     public boolean equals(Object obj) {\r
146         if (this == obj) {\r
147             return true;\r
148         }\r
149         if (obj == null) {\r
150             return false;\r
151         }\r
152         if (getClass() != obj.getClass()) {\r
153             return false;\r
154         }\r
155         Leafref other = (Leafref) obj;\r
156         if (path == null) {\r
157             if (other.path != null) {\r
158                 return false;\r
159             }\r
160         } else if (!path.equals(other.path)) {\r
161             return false;\r
162         }\r
163         if (units == null) {\r
164             if (other.units != null) {\r
165                 return false;\r
166             }\r
167         } else if (!units.equals(other.units)) {\r
168             return false;\r
169         }\r
170         if (xpath == null) {\r
171             if (other.xpath != null) {\r
172                 return false;\r
173             }\r
174         } else if (!xpath.equals(other.xpath)) {\r
175             return false;\r
176         }\r
177         return true;\r
178     }\r
179 \r
180     @Override\r
181     public String toString() {\r
182         StringBuilder builder = new StringBuilder();\r
183         builder.append("Leafref [path=");\r
184         builder.append(path);\r
185         builder.append(", xpath=");\r
186         builder.append(xpath);\r
187         builder.append(", units=");\r
188         builder.append(units);\r
189         builder.append("]");\r
190         return builder.toString();\r
191     }\r
192 }\r