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.yangtools.yang.model.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
20 import com.google.common.base.Preconditions;
23 * The <code>default</code> implementation of Instance Leafref Type Definition
26 * @see LeafrefTypeDefinition
28 public final class Leafref implements LeafrefTypeDefinition {
29 private static final QName NAME = BaseTypes.constructQName("leafref");
30 private static final SchemaPath PATH = BaseTypes.schemaPath(NAME);
31 private static final String DESCRIPTION = "The leafref type is used to reference a particular leaf instance in the data tree.";
32 private static final String REF = "https://tools.ietf.org/html/rfc6020#section-9.9";
34 private final RevisionAwareXPath xpath;
35 private final SchemaPath path;
38 public Leafref(final RevisionAwareXPath xpath) {
43 private Leafref(final SchemaPath path, final RevisionAwareXPath target) {
44 this.path = Preconditions.checkNotNull(path,"path must be specified");
45 this.xpath = Preconditions.checkNotNull(target,"target must not be null.");
48 public static Leafref create(final SchemaPath path,final RevisionAwareXPath target) {
49 return new Leafref(path,target);
53 public LeafrefTypeDefinition getBaseType() {
58 public String getUnits() {
63 public Object getDefaultValue() {
68 public QName getQName() {
73 public SchemaPath getPath() {
78 public String getDescription() {
83 public String getReference() {
88 public Status getStatus() {
89 return Status.CURRENT;
93 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
94 return Collections.emptyList();
98 public RevisionAwareXPath getPathStatement() {
103 public int hashCode() {
104 final int prime = 31;
106 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
111 public boolean equals(final Object obj) {
118 if (getClass() != obj.getClass()) {
121 Leafref other = (Leafref) obj;
123 if (other.xpath != null) {
126 } else if (!xpath.equals(other.xpath)) {
133 public String toString() {
134 StringBuilder builder = new StringBuilder();
135 builder.append("type ");
136 builder.append(NAME);
137 builder.append(" [xpath=");
138 builder.append(xpath);
140 return builder.toString();