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.InstanceIdentifierTypeDefinition;
21 * The <code>default</code> implementation of Instance Identifier Type
22 * Definition interface.
24 * @see InstanceIdentifierTypeDefinition
26 public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
27 private static final QName NAME = BaseTypes.constructQName("instance-identifier");
28 private static final SchemaPath PATH = new SchemaPath(Collections.singletonList(NAME), true);
29 private static final String DESCRIPTION = "The instance-identifier built-in type is used to "
30 + "uniquely identify a particular instance node in the data tree.";
31 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.13";
33 private final RevisionAwareXPath xpath;
34 private static final String UNITS = "";
35 private boolean requireInstance = true;
37 private static final int HASH_BOOLEAN_TRUE = 1231;
38 private static final int HASH_BOOLEAN_FALSE = 1237;
40 public InstanceIdentifier(final RevisionAwareXPath xpath) {
44 public InstanceIdentifier(final RevisionAwareXPath xpath, final boolean requireInstance) {
46 this.requireInstance = requireInstance;
53 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
56 public InstanceIdentifierTypeDefinition getBaseType() {
63 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
66 public String getUnits() {
74 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
78 public Object getDefaultValue() {
85 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
88 public QName getQName() {
95 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
98 public SchemaPath getPath() {
106 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
109 public String getDescription() {
116 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
119 public String getReference() {
126 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
129 public Status getStatus() {
130 return Status.CURRENT;
137 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getExtensionSchemaNodes
141 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
142 return Collections.emptyList();
148 * @see org.opendaylight.yangtools.yang.model.api.type.
149 * InstanceIdentifierTypeDefinition# getPathStatement()
152 public RevisionAwareXPath getPathStatement() {
159 * @see org.opendaylight.yangtools.yang.model.api.type.
160 * InstanceIdentifierTypeDefinition# requireInstance()
163 public boolean requireInstance() {
164 return requireInstance;
168 public int hashCode() {
169 final int prime = 31;
171 result = prime * result + (requireInstance ? HASH_BOOLEAN_TRUE : HASH_BOOLEAN_FALSE);
172 result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
177 public boolean equals(Object obj) {
184 if (getClass() != obj.getClass()) {
187 InstanceIdentifier other = (InstanceIdentifier) obj;
188 if (requireInstance != other.requireInstance) {
192 if (other.xpath != null) {
195 } else if (!xpath.equals(other.xpath)) {