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 interface.
23 * @see LeafrefTypeDefinition
25 public class Leafref implements LeafrefTypeDefinition {
26 private static final QName name = BaseTypes.constructQName("leafref");
27 private static final String description = "The leafref type is used to reference a " +
28 "particular leaf instance in the data tree.";
29 private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.9";
30 private final SchemaPath path = BaseTypes.schemaPath(name);
31 private final RevisionAwareXPath xpath;
32 private final String units = "";
34 public Leafref(RevisionAwareXPath xpath) {
42 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
45 public LeafrefTypeDefinition getBaseType() {
52 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
55 public String getUnits() {
62 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
65 public Object getDefaultValue() {
72 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
75 public QName getQName() {
82 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
85 public SchemaPath getPath() {
92 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
95 public String getDescription() {
102 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
105 public String getReference() {
112 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
115 public Status getStatus() {
116 return Status.CURRENT;
122 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()
125 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
126 return Collections.emptyList();
133 * org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition#getPathStatement()
136 public RevisionAwareXPath getPathStatement() {
141 public int hashCode() {
142 final int prime = 31;
144 result = prime * result + ((path == null) ? 0 : path.hashCode());
145 result = prime * result + ((units == null) ? 0 : units.hashCode());
146 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
151 public boolean equals(Object obj) {
158 if (getClass() != obj.getClass()) {
161 Leafref other = (Leafref) obj;
163 if (other.path != null) {
166 } else if (!path.equals(other.path)) {
170 if (other.units != null) {
173 } else if (!units.equals(other.units)) {
177 if (other.xpath != null) {
180 } else if (!xpath.equals(other.xpath)) {
187 public String toString() {
188 StringBuilder builder = new StringBuilder();
189 builder.append("Leafref [path=");
190 builder.append(path);
191 builder.append(", xpath=");
192 builder.append(xpath);
193 builder.append(", units=");
194 builder.append(units);
196 return builder.toString();