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