2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\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
8 package org.opendaylight.controller.yang.model.util;
\r
10 import java.net.URI;
\r
11 import java.util.Collections;
\r
12 import java.util.Date;
\r
13 import java.util.List;
\r
15 import org.opendaylight.controller.yang.common.QName;
\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 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
20 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
\r
23 * The <code>default</code> implementation of Instance Leafref Type Definition
\r
26 * @see LeafrefTypeDefinition
\r
28 public class Leafref implements LeafrefTypeDefinition {
\r
29 private static final QName name = BaseTypes.constructQName("leafref");
\r
30 private static final String description = "The leafref type is used to reference a "
\r
31 + "particular leaf instance in the data tree.";
\r
32 private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";
\r
33 private final SchemaPath path;
\r
34 private final RevisionAwareXPath xpath;
\r
35 private final String units = "";
\r
36 private final LeafrefTypeDefinition baseType;
\r
38 private Leafref(final RevisionAwareXPath xpath) {
\r
40 this.path = BaseTypes.schemaPath(name);
\r
41 this.baseType = this;
\r
44 public Leafref(final List<String> actualPath, final URI namespace,
\r
45 final Date revision, final RevisionAwareXPath xpath) {
\r
47 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
\r
49 baseType = new Leafref(xpath);
\r
52 public Leafref(final List<String> actualPath, final URI namespace,
\r
53 final Date revision, final LeafrefTypeDefinition baseType,
\r
54 final RevisionAwareXPath xpath) {
\r
56 this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
\r
58 this.baseType = baseType;
\r
65 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
68 public LeafrefTypeDefinition getBaseType() {
\r
75 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
78 public String getUnits() {
\r
86 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
\r
90 public Object getDefaultValue() {
\r
97 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
100 public QName getQName() {
\r
107 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
110 public SchemaPath getPath() {
\r
118 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
121 public String getDescription() {
\r
122 return description;
\r
128 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
131 public String getReference() {
\r
138 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
141 public Status getStatus() {
\r
142 return Status.CURRENT;
\r
149 * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes
\r
153 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
154 return Collections.emptyList();
\r
161 * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition
\r
162 * #getPathStatement()
\r
165 public RevisionAwareXPath getPathStatement() {
\r
170 public int hashCode() {
\r
171 final int prime = 31;
\r
173 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
174 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
175 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
\r
180 public boolean equals(Object obj) {
\r
187 if (getClass() != obj.getClass()) {
\r
190 Leafref other = (Leafref) obj;
\r
191 if (path == null) {
\r
192 if (other.path != null) {
\r
195 } else if (!path.equals(other.path)) {
\r
198 if (units == null) {
\r
199 if (other.units != null) {
\r
202 } else if (!units.equals(other.units)) {
\r
205 if (xpath == null) {
\r
206 if (other.xpath != null) {
\r
209 } else if (!xpath.equals(other.xpath)) {
\r
216 public String toString() {
\r
217 StringBuilder builder = new StringBuilder();
\r
218 builder.append("Leafref [path=");
\r
219 builder.append(path);
\r
220 builder.append(", xpath=");
\r
221 builder.append(xpath);
\r
222 builder.append(", units=");
\r
223 builder.append(units);
\r
224 builder.append("]");
\r
225 return builder.toString();
\r