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
27 public final class Leafref implements LeafrefTypeDefinition {
28 private static final QName NAME = BaseTypes.constructQName("leafref");
29 private static final SchemaPath PATH = SchemaPath.create(true, NAME);
30 private static final String DESCRIPTION = "The leafref type is used to reference a particular leaf instance in the data tree.";
31 private static final String REF = "https://tools.ietf.org/html/rfc6020#section-9.9";
33 private final RevisionAwareXPath xpath;
34 private final SchemaPath path;
37 public Leafref(final RevisionAwareXPath xpath) {
41 private Leafref(final SchemaPath path, final RevisionAwareXPath target) {
42 this.path = Preconditions.checkNotNull(path,"path must be specified");
43 this.xpath = Preconditions.checkNotNull(target,"target must not be null.");
46 public static Leafref create(final SchemaPath path, final RevisionAwareXPath target) {
47 return new Leafref(path,target);
51 public LeafrefTypeDefinition getBaseType() {
56 public String getUnits() {
61 public Object getDefaultValue() {
66 public QName getQName() {
71 public SchemaPath getPath() {
76 public String getDescription() {
81 public String getReference() {
86 public Status getStatus() {
87 return Status.CURRENT;
91 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
92 return Collections.emptyList();
96 public RevisionAwareXPath getPathStatement() {
101 public int hashCode() {
102 final int prime = 31;
104 result = prime * result + Objects.hashCode(xpath);
109 public boolean equals(final Object obj) {
116 if (getClass() != obj.getClass()) {
119 Leafref other = (Leafref) obj;
120 return Objects.equals(xpath, other.xpath);
124 public String toString() {
125 StringBuilder builder = new StringBuilder();
126 builder.append("type ");
127 builder.append(NAME);
128 builder.append(" [xpath=");
129 builder.append(xpath);
131 return builder.toString();