Modified construction of built-in yang types.
[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     private static final QName name = BaseTypes
27             .constructQName("instance-identifier");
28     private static final String description = "The instance-identifier built-in type is used to " +
29                 "uniquely identify a particular instance node in the data tree.";
30     private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13";
31
32     private final transient SchemaPath path;
33     private final RevisionAwareXPath xpath;
34     private final String units = "";
35     private final InstanceIdentifierTypeDefinition baseType;
36     private final boolean requireInstance;
37
38     public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
39         super();
40         this.path = path;
41         this.xpath = xpath;
42         this.requireInstance = requireInstance;
43         this.baseType = this;
44     }
45
46     /*
47      * (non-Javadoc)
48      *
49      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
50      */
51     @Override
52     public InstanceIdentifierTypeDefinition getBaseType() {
53         return baseType;
54     }
55
56     /*
57      * (non-Javadoc)
58      *
59      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
60      */
61     @Override
62     public String getUnits() {
63         return units;
64     }
65
66     /*
67      * (non-Javadoc)
68      *
69      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
70      */
71     @Override
72     public Object getDefaultValue() {
73         return xpath;
74     }
75
76     /*
77      * (non-Javadoc)
78      *
79      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
80      */
81     @Override
82     public QName getQName() {
83         return name;
84     }
85
86     /*
87      * (non-Javadoc)
88      *
89      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
90      */
91     @Override
92     public SchemaPath getPath() {
93         return path;
94     }
95
96     /*
97      * (non-Javadoc)
98      *
99      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
100      */
101     @Override
102     public String getDescription() {
103         return description;
104     }
105
106     /*
107      * (non-Javadoc)
108      *
109      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
110      */
111     @Override
112     public String getReference() {
113         return reference;
114     }
115
116     /*
117      * (non-Javadoc)
118      *
119      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
120      */
121     @Override
122     public Status getStatus() {
123         return Status.CURRENT;
124     }
125
126     /*
127      * (non-Javadoc)
128      *
129      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()
130      */
131     @Override
132     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
133         return Collections.emptyList();
134     }
135
136     /*
137      * (non-Javadoc)
138      *
139      * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
140      * getPathStatement()
141      */
142     @Override
143     public RevisionAwareXPath getPathStatement() {
144         return xpath;
145     }
146
147     /*
148      * (non-Javadoc)
149      *
150      * @see org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition#
151      * requireInstance()
152      */
153     @Override
154     public boolean requireInstance() {
155         return requireInstance;
156     }
157
158 }