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;
12 import org.opendaylight.yangtools.concepts.Immutable;
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 * Instance Identifier has only two possible variants - one with
25 * {@link #requireInstance()} which returns true, other one
28 * @see InstanceIdentifierTypeDefinition
29 * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#instanceIdentifierType()} instead
32 public final class InstanceIdentifierType implements InstanceIdentifierTypeDefinition, Immutable {
34 private static final QName NAME = BaseTypes.INSTANCE_IDENTIFIER_QNAME;
35 private static final SchemaPath PATH = SchemaPath.create(true, NAME);
36 private static final String DESCRIPTION = "The instance-identifier built-in type is used to "
37 + "uniquely identify a particular instance node in the data tree.";
38 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.13";
39 private static final String UNITS = "";
41 private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_TRUE = new InstanceIdentifierType(true);
42 private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_FALSE = new InstanceIdentifierType(false);
44 private final Boolean requireInstance;
46 private InstanceIdentifierType(final boolean requiredInstance) {
47 this.requireInstance = requiredInstance;
50 public static InstanceIdentifierType getInstance() {
51 return INSTANCE_WITH_REQUIRED_TRUE;
54 public static InstanceIdentifierType create(final boolean requireInstance) {
55 return requireInstance ? INSTANCE_WITH_REQUIRED_TRUE : INSTANCE_WITH_REQUIRED_FALSE;
62 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
65 public InstanceIdentifierTypeDefinition getBaseType() {
72 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
75 public String getUnits() {
83 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue()
86 public Object getDefaultValue() {
93 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
96 public QName getQName() {
103 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
106 public SchemaPath getPath() {
114 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
117 public String getDescription() {
124 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
127 public String getReference() {
134 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
137 public Status getStatus() {
138 return Status.CURRENT;
145 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getExtensionSchemaNodes()
148 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
149 return Collections.emptyList();
155 * @see org.opendaylight.yangtools.yang.model.api.type.
156 * InstanceIdentifierTypeDefinition# getPathStatement()
160 public RevisionAwareXPath getPathStatement() {
167 * @see org.opendaylight.yangtools.yang.model.api.type.
168 * InstanceIdentifierTypeDefinition# requireInstance()
171 public boolean requireInstance() {
172 return requireInstance;
176 public int hashCode() {
177 final int prime = 31;
179 result = prime * result + requireInstance.hashCode();
184 public boolean equals(final Object obj) {
191 if (getClass() != obj.getClass()) {
194 InstanceIdentifierType other = (InstanceIdentifierType) obj;
195 return requireInstance.equals(other.requireInstance);