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 com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import org.opendaylight.yangtools.yang.model.api.Status;
18 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
22 * The <code>default</code> implementation of Instance Leafref Type Definition
25 * @see LeafrefTypeDefinition
26 * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#leafrefTypeBuilder(SchemaPath)} instead
29 public final class Leafref implements LeafrefTypeDefinition {
30 private static final QName NAME = BaseTypes.constructQName("leafref");
31 private static final SchemaPath PATH = SchemaPath.create(true, NAME);
32 private static final String DESCRIPTION = "The leafref type is used to reference a particular leaf instance in the data tree.";
33 private static final String REF = "https://tools.ietf.org/html/rfc6020#section-9.9";
35 private final RevisionAwareXPath xpath;
36 private final SchemaPath path;
39 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 + Objects.hashCode(xpath);
111 public boolean equals(final Object obj) {
118 if (getClass() != obj.getClass()) {
121 Leafref other = (Leafref) obj;
122 return Objects.equals(xpath, other.xpath);
126 public String toString() {
127 StringBuilder builder = new StringBuilder();
128 builder.append("type ");
129 builder.append(NAME);
130 builder.append(" [xpath=");
131 builder.append(xpath);
133 return builder.toString();