2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.yang.model.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
15 import org.opendaylight.controller.yang.model.api.SchemaPath;
16 import org.opendaylight.controller.yang.model.api.Status;
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
21 * The <code>default</code> implementation of Instance Leafref Type Definition
24 * @see LeafrefTypeDefinition
26 public final class Leafref implements LeafrefTypeDefinition {
27 private static final QName name = BaseTypes.constructQName("leafref");
28 private static final String description = "The leafref type is used to reference a "
29 + "particular leaf instance in the data tree.";
30 private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";
31 private final SchemaPath path;
32 private final RevisionAwareXPath xpath;
33 private final String units = "";
34 private final LeafrefTypeDefinition baseType;
36 private Leafref(final RevisionAwareXPath xpath) {
38 this.path = BaseTypes.schemaPath(name);
42 public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
46 baseType = new Leafref(xpath);
53 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
56 public LeafrefTypeDefinition getBaseType() {
63 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
66 public String getUnits() {
74 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
78 public Object getDefaultValue() {
85 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
88 public QName getQName() {
95 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
98 public SchemaPath getPath() {
106 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
109 public String getDescription() {
116 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
119 public String getReference() {
126 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
129 public Status getStatus() {
130 return Status.CURRENT;
137 * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes
141 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
142 return Collections.emptyList();
149 * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition
150 * #getPathStatement()
153 public RevisionAwareXPath getPathStatement() {
158 public int hashCode() {
159 final int prime = 31;
161 result = prime * result + ((path == null) ? 0 : path.hashCode());
162 result = prime * result + ((units == null) ? 0 : units.hashCode());
163 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
168 public boolean equals(Object obj) {
175 if (getClass() != obj.getClass()) {
178 Leafref other = (Leafref) obj;
180 if (other.path != null) {
183 } else if (!path.equals(other.path)) {
187 if (other.units != null) {
190 } else if (!units.equals(other.units)) {
194 if (other.xpath != null) {
197 } else if (!xpath.equals(other.xpath)) {
204 public String toString() {
205 StringBuilder builder = new StringBuilder();
206 builder.append("Leafref [path=");
207 builder.append(path);
208 builder.append(", xpath=");
209 builder.append(xpath);
210 builder.append(", units=");
211 builder.append(units);
213 return builder.toString();