4c17fa6154248fb711c7bd844feb60e65cfd4ba3
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / InstanceIdentifier.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.controller.yang.model.util;
9
10 import java.util.Collections;
11 import java.util.List;
12
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
15 import org.opendaylight.controller.yang.model.api.SchemaPath;
16 import org.opendaylight.controller.yang.model.api.Status;
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;
19
20 /**
21  * The <code>default</code> implementation of Instance Identifier Type Definition interface.
22  *
23  * @see InstanceIdentifierTypeDefinition
24  */
25 public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
26
27     private static final QName name = BaseTypes
28             .constructQName("instance-identifier");
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";
32
33     private final transient SchemaPath path;
34     private final RevisionAwareXPath xpath;
35     private final String units = "";
36     private final InstanceIdentifierTypeDefinition baseType;
37     private final boolean requireInstance;
38
39     private InstanceIdentifier(RevisionAwareXPath xpath, boolean requireInstance) {
40         super();
41         path = BaseTypes.schemaPath(name);
42         this.xpath = xpath;
43         this.requireInstance = requireInstance;
44         this.baseType = this;
45     }
46
47     public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
48         super();
49         this.path = path;
50         this.xpath = xpath;
51         this.requireInstance = requireInstance;
52         this.baseType = new InstanceIdentifier(xpath, requireInstance);
53     }
54
55     /*
56      * (non-Javadoc)
57      *
58      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
59      */
60     @Override
61     public InstanceIdentifierTypeDefinition getBaseType() {
62         return baseType;
63     }
64
65     /*
66      * (non-Javadoc)
67      *
68      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
69      */
70     @Override
71     public String getUnits() {
72         return units;
73     }
74
75     /*
76      * (non-Javadoc)
77      *
78      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
79      */
80     @Override
81     public Object getDefaultValue() {
82         return xpath;
83     }
84
85     /*
86      * (non-Javadoc)
87      *
88      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
89      */
90     @Override
91     public QName getQName() {
92         return name;
93     }
94
95     /*
96      * (non-Javadoc)
97      *
98      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
99      */
100     @Override
101     public SchemaPath getPath() {
102         return path;
103     }
104
105     /*
106      * (non-Javadoc)
107      *
108      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
109      */
110     @Override
111     public String getDescription() {
112         return description;
113     }
114
115     /*
116      * (non-Javadoc)
117      *
118      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
119      */
120     @Override
121     public String getReference() {
122         return reference;
123     }
124
125     /*
126      * (non-Javadoc)
127      *
128      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
129      */
130     @Override
131     public Status getStatus() {
132         return Status.CURRENT;
133     }
134
135     /*
136      * (non-Javadoc)
137      *
138      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()
139      */
140     @Override
141     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
142         return Collections.emptyList();
143     }
144
145     /*
146      * (non-Javadoc)
147      *
148      * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
149      * getPathStatement()
150      */
151     @Override
152     public RevisionAwareXPath getPathStatement() {
153         return xpath;
154     }
155
156     /*
157      * (non-Javadoc)
158      *
159      * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
160      * requireInstance()
161      */
162     @Override
163     public boolean requireInstance() {
164         return requireInstance;
165     }
166
167 }