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 QName baseQName;
36 public IdentityrefTypeBuilder(String baseString) {
37 this.baseString = baseString;
40 public String getBaseString() {
44 public void setBaseQName(QName baseQName) {
45 this.baseQName = baseQName;
49 public TypeDefinition<?> getType() {
54 public TypeDefinitionBuilder getTypedef() {
59 public void setType(final TypeDefinition<?> type) {
60 throw new IllegalStateException("Can not set type to "
61 + IdentityrefTypeBuilder.class.getSimpleName());
65 public void setType(final TypeDefinitionBuilder tdb) {
66 throw new IllegalStateException("Can not set type to "
67 + IdentityrefTypeBuilder.class.getSimpleName());
71 public IdentityrefType build() {
72 return new IdentityrefType(baseQName);
76 public void setPath(final SchemaPath schemaPath) {
77 throw new IllegalStateException("Can not set path to "
78 + IdentityrefTypeBuilder.class.getSimpleName());
82 public void setDescription(final String description) {
83 throw new IllegalStateException("Can not set description to "
84 + IdentityrefTypeBuilder.class.getSimpleName());
88 public void setReference(final String reference) {
89 throw new IllegalStateException("Can not set reference to "
90 + IdentityrefTypeBuilder.class.getSimpleName());
94 public void setStatus(final Status status) {
95 throw new IllegalStateException("Can not set status to "
96 + IdentityrefTypeBuilder.class.getSimpleName());
100 public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
101 throw new IllegalStateException("Can not add unknown node to "
102 + IdentityrefTypeBuilder.class.getSimpleName());
106 public QName getQName() {
111 public SchemaPath getPath() {
116 public String getDescription() {
121 public String getReference() {
126 public Status getStatus() {
131 public List<RangeConstraint> getRanges() {
132 return Collections.emptyList();
136 public void setRanges(List<RangeConstraint> ranges) {
137 throw new IllegalStateException("Can not set ranges to "
138 + IdentityrefTypeBuilder.class.getSimpleName());
142 public List<LengthConstraint> getLengths() {
143 return Collections.emptyList();
147 public void setLengths(List<LengthConstraint> lengths) {
148 throw new IllegalStateException("Can not set lengths to "
149 + IdentityrefTypeBuilder.class.getSimpleName());
153 public List<PatternConstraint> getPatterns() {
154 return Collections.emptyList();
158 public void setPatterns(List<PatternConstraint> patterns) {
159 throw new IllegalStateException("Can not set patterns to "
160 + IdentityrefTypeBuilder.class.getSimpleName());
164 public Integer getFractionDigits() {
169 public void setFractionDigits(Integer fractionDigits) {
170 throw new IllegalStateException("Can not set fraction digits to "
171 + IdentityrefTypeBuilder.class.getSimpleName());
175 public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
176 return Collections.emptyList();
180 public Object getDefaultValue() {
185 public void setDefaultValue(Object defaultValue) {
186 throw new IllegalStateException("Can not set default value to "
187 + IdentityrefTypeBuilder.class.getSimpleName());
191 public String getUnits() {
196 public void setUnits(String units) {
197 throw new IllegalStateException("Can not set units to "
198 + IdentityrefTypeBuilder.class.getSimpleName());
202 public String toString() {
203 final StringBuilder result = new StringBuilder(
204 IdentityrefTypeBuilder.class.getSimpleName() + "[");
205 result.append(", base=" + baseQName);
207 return result.toString();