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 public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
46 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
49 public LeafrefTypeDefinition getBaseType() {
56 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
59 public String getUnits() {
67 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
71 public Object getDefaultValue() {
78 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
81 public QName getQName() {
88 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
91 public SchemaPath getPath() {
99 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
102 public String getDescription() {
109 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
112 public String getReference() {
119 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
122 public Status getStatus() {
123 return Status.CURRENT;
130 * org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes
134 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
135 return Collections.emptyList();
142 * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition
143 * #getPathStatement()
146 public RevisionAwareXPath getPathStatement() {
151 public int hashCode() {
152 final int prime = 31;
154 result = prime * result + ((path == null) ? 0 : path.hashCode());
155 result = prime * result + ((units == null) ? 0 : units.hashCode());
156 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
161 public boolean equals(Object obj) {
168 if (getClass() != obj.getClass()) {
171 Leafref other = (Leafref) obj;
173 if (other.path != null) {
176 } else if (!path.equals(other.path)) {
180 if (other.units != null) {
183 } else if (!units.equals(other.units)) {
187 if (other.xpath != null) {
190 } else if (!xpath.equals(other.xpath)) {
197 public String toString() {
198 StringBuilder builder = new StringBuilder();
199 builder.append("Leafref [path=");
200 builder.append(path);
201 builder.append(", xpath=");
202 builder.append(xpath);
203 builder.append(", units=");
204 builder.append(units);
206 return builder.toString();