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.controller.yang.model.parser.builder.impl;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.TypeDefinition;
17 import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
18 import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
19 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
20 import org.opendaylight.controller.yang.model.parser.builder.api.AbstractTypeAwareBuilder;
21 import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
22 import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
23 import org.opendaylight.controller.yang.model.util.IdentityrefType;
26 * Builder for YANG union type. User can add type to this union as
27 * TypeDefinition object (resolved type) or in form of TypeDefinitionBuilder.
28 * When build is called, types in builder form will be built and add to resolved
31 public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
32 TypeDefinitionBuilder, Builder {
33 private final String baseString;
34 private final SchemaPath schemaPath;
35 private QName baseQName;
38 public IdentityrefTypeBuilder(final String baseString, SchemaPath schemaPath) {
39 this.baseString = baseString;
40 this.schemaPath = schemaPath;
43 public String getBaseString() {
47 public void setBaseQName(QName baseQName) {
48 this.baseQName = baseQName;
52 public TypeDefinition<?> getType() {
57 public TypeDefinitionBuilder getTypedef() {
62 public void setType(final TypeDefinition<?> type) {
63 throw new IllegalStateException("Can not set type to "
64 + IdentityrefTypeBuilder.class.getSimpleName());
68 public void setType(final TypeDefinitionBuilder tdb) {
69 throw new IllegalStateException("Can not set type to "
70 + IdentityrefTypeBuilder.class.getSimpleName());
74 public IdentityrefType build() {
75 return new IdentityrefType(baseQName, schemaPath);
79 public void setPath(final SchemaPath schemaPath) {
80 throw new IllegalStateException("Can not set path to "
81 + IdentityrefTypeBuilder.class.getSimpleName());
85 public void setDescription(final String description) {
86 throw new IllegalStateException("Can not set description to "
87 + IdentityrefTypeBuilder.class.getSimpleName());
91 public void setReference(final String reference) {
92 throw new IllegalStateException("Can not set reference to "
93 + IdentityrefTypeBuilder.class.getSimpleName());
97 public void setStatus(final Status status) {
98 throw new IllegalStateException("Can not set status to "
99 + IdentityrefTypeBuilder.class.getSimpleName());
103 public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
104 throw new IllegalStateException("Can not add unknown node to "
105 + IdentityrefTypeBuilder.class.getSimpleName());
109 public QName getQName() {
114 public SchemaPath getPath() {
119 public String getDescription() {
124 public String getReference() {
129 public Status getStatus() {
134 public List<RangeConstraint> getRanges() {
135 return Collections.emptyList();
139 public void setRanges(List<RangeConstraint> ranges) {
140 throw new IllegalStateException("Can not set ranges to "
141 + IdentityrefTypeBuilder.class.getSimpleName());
145 public List<LengthConstraint> getLengths() {
146 return Collections.emptyList();
150 public void setLengths(List<LengthConstraint> lengths) {
151 throw new IllegalStateException("Can not set lengths to "
152 + IdentityrefTypeBuilder.class.getSimpleName());
156 public List<PatternConstraint> getPatterns() {
157 return Collections.emptyList();
161 public void setPatterns(List<PatternConstraint> patterns) {
162 throw new IllegalStateException("Can not set patterns to "
163 + IdentityrefTypeBuilder.class.getSimpleName());
167 public Integer getFractionDigits() {
172 public void setFractionDigits(Integer fractionDigits) {
173 throw new IllegalStateException("Can not set fraction digits to "
174 + IdentityrefTypeBuilder.class.getSimpleName());
178 public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
179 return Collections.emptyList();
183 public Object getDefaultValue() {
188 public void setDefaultValue(Object defaultValue) {
189 throw new IllegalStateException("Can not set default value to "
190 + IdentityrefTypeBuilder.class.getSimpleName());
194 public String getUnits() {
199 public void setUnits(String units) {
200 throw new IllegalStateException("Can not set units to "
201 + IdentityrefTypeBuilder.class.getSimpleName());
205 public String toString() {
206 final StringBuilder result = new StringBuilder(
207 IdentityrefTypeBuilder.class.getSimpleName() + "[");
208 result.append(", base=" + baseQName);
210 return result.toString();