*/
package org.opendaylight.yangtools.yang.model.util;
+import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.List;
-
+import java.util.Objects;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
-import com.google.common.base.Preconditions;
-
/**
* The <code>default</code> implementation of Instance Leafref Type Definition
* interface.
*
* @see LeafrefTypeDefinition
+ * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#leafrefTypeBuilder(SchemaPath)} instead
*/
+@Deprecated
public final class Leafref implements LeafrefTypeDefinition {
private static final QName NAME = BaseTypes.constructQName("leafref");
- private static final SchemaPath PATH = BaseTypes.schemaPath(NAME);
+ private static final SchemaPath PATH = SchemaPath.create(true, NAME);
private static final String DESCRIPTION = "The leafref type is used to reference a particular leaf instance in the data tree.";
private static final String REF = "https://tools.ietf.org/html/rfc6020#section-9.9";
@Deprecated
public Leafref(final RevisionAwareXPath xpath) {
- this(PATH,xpath);
-
+ this(PATH, xpath);
}
private Leafref(final SchemaPath path, final RevisionAwareXPath target) {
this.xpath = Preconditions.checkNotNull(target,"target must not be null.");
}
- public static Leafref create(final SchemaPath path,final RevisionAwareXPath target) {
+ public static Leafref create(final SchemaPath path, final RevisionAwareXPath target) {
return new Leafref(path,target);
}
@Override
public Object getDefaultValue() {
- return this;
+ return null;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
+ result = prime * result + Objects.hashCode(xpath);
return result;
}
return false;
}
Leafref other = (Leafref) obj;
- if (xpath == null) {
- if (other.xpath != null) {
- return false;
- }
- } else if (!xpath.equals(other.xpath)) {
- return false;
- }
- return true;
+ return Objects.equals(xpath, other.xpath);
}
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("type ");
- builder.append(NAME);
- builder.append(" [xpath=");
- builder.append(xpath);
- builder.append("]");
- return builder.toString();
+ return "type " +
+ NAME +
+ " [xpath=" +
+ xpath +
+ "]";
}
}