BUG-865: mark yang-model-util types as deprecated
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / InstanceIdentifierType.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.util;
9
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;
19
20 /**
21  * The <code>default</code> implementation of Instance Identifier Type
22  * Definition interface.
23  *
24  * Instance Identifier has only two possible variants - one with
25  * {@link #requireInstance()} which returns true, other one
26  * returns false.
27  *
28  * @see InstanceIdentifierTypeDefinition
29  * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#instanceIdentifierType()} instead
30  */
31 @Deprecated
32 public final class InstanceIdentifierType implements InstanceIdentifierTypeDefinition, Immutable {
33
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 = "";
40
41     private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_TRUE = new InstanceIdentifierType(true);
42     private static final InstanceIdentifierType INSTANCE_WITH_REQUIRED_FALSE = new InstanceIdentifierType(false);
43
44     private final Boolean requireInstance;
45
46     private InstanceIdentifierType(final boolean requiredInstance) {
47         this.requireInstance = requiredInstance;
48     }
49
50     public static InstanceIdentifierType getInstance() {
51         return INSTANCE_WITH_REQUIRED_TRUE;
52     }
53
54     public static InstanceIdentifierType create(final boolean requireInstance) {
55         return requireInstance ? INSTANCE_WITH_REQUIRED_TRUE : INSTANCE_WITH_REQUIRED_FALSE;
56     }
57
58     /*
59      * (non-Javadoc)
60      *
61      * @see
62      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
63      */
64     @Override
65     public InstanceIdentifierTypeDefinition getBaseType() {
66         return null;
67     }
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
73      */
74     @Override
75     public String getUnits() {
76         return UNITS;
77     }
78
79     /*
80      * (non-Javadoc)
81      *
82      * @see
83      * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue()
84      */
85     @Override
86     public Object getDefaultValue() {
87         return null;
88     }
89
90     /*
91      * (non-Javadoc)
92      *
93      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
94      */
95     @Override
96     public QName getQName() {
97         return NAME;
98     }
99
100     /*
101      * (non-Javadoc)
102      *
103      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
104      */
105     @Override
106     public SchemaPath getPath() {
107         return PATH;
108     }
109
110     /*
111      * (non-Javadoc)
112      *
113      * @see
114      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
115      */
116     @Override
117     public String getDescription() {
118         return DESCRIPTION;
119     }
120
121     /*
122      * (non-Javadoc)
123      *
124      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
125      */
126     @Override
127     public String getReference() {
128         return REFERENCE;
129     }
130
131     /*
132      * (non-Javadoc)
133      *
134      * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
135      */
136     @Override
137     public Status getStatus() {
138         return Status.CURRENT;
139     }
140
141     /*
142      * (non-Javadoc)
143      *
144      * @see
145      * org.opendaylight.yangtools.yang.model.api.SchemaNode#getExtensionSchemaNodes()
146      */
147     @Override
148     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
149         return Collections.emptyList();
150     }
151
152     /*
153      * (non-Javadoc)
154      *
155      * @see org.opendaylight.yangtools.yang.model.api.type.
156      * InstanceIdentifierTypeDefinition# getPathStatement()
157      */
158     @Override
159     @Deprecated
160     public RevisionAwareXPath getPathStatement() {
161         return null;
162     }
163
164     /*
165      * (non-Javadoc)
166      *
167      * @see org.opendaylight.yangtools.yang.model.api.type.
168      * InstanceIdentifierTypeDefinition# requireInstance()
169      */
170     @Override
171     public boolean requireInstance() {
172         return requireInstance;
173     }
174
175     @Override
176     public int hashCode() {
177         final int prime = 31;
178         int result = 1;
179         result = prime * result + requireInstance.hashCode();
180         return result;
181     }
182
183     @Override
184     public boolean equals(final Object obj) {
185         if (this == obj) {
186             return true;
187         }
188         if (obj == null) {
189             return false;
190         }
191         if (getClass() != obj.getClass()) {
192             return false;
193         }
194         InstanceIdentifierType other = (InstanceIdentifierType) obj;
195         return requireInstance.equals(other.requireInstance);
196     }
197 }