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