import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.Status;
import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.util.IdentityrefType;
import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.Builder;
import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.parser.util.YangParseException;
/**
* Builder for YANG union type. User can add type to this union as
* When build is called, types in builder form will be built and add to resolved
* types.
*/
-public class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements
- TypeDefinitionBuilder, Builder {
- private final int line;
+public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder implements TypeDefinitionBuilder {
+ private static final String NAME = "identityref";
+
private final String baseString;
private final SchemaPath schemaPath;
private QName baseQName;
-
- public IdentityrefTypeBuilder(final String baseString, final SchemaPath schemaPath, final int line) {
- this.line = line;
+ IdentityrefTypeBuilder(final String baseString, final SchemaPath schemaPath, final int line) {
+ super(line, null);
this.baseString = baseString;
this.schemaPath = schemaPath;
}
+ @Override
+ public IdentityrefType build() {
+ return new IdentityrefType(baseQName, schemaPath);
+ }
+
public String getBaseString() {
return baseString;
}
this.baseQName = baseQName;
}
- @Override
- public int getLine() {
- return line;
- }
-
@Override
public TypeDefinition<?> getType() {
return null;
@Override
public void setType(final TypeDefinition<?> type) {
- throw new IllegalStateException("Can not set type to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set type to " + NAME);
}
@Override
- public void setType(final TypeDefinitionBuilder tdb) {
- throw new IllegalStateException("Can not set type to "
- + IdentityrefTypeBuilder.class.getSimpleName());
- }
-
- @Override
- public IdentityrefType build() {
- return new IdentityrefType(baseQName, schemaPath);
+ public void setTypedef(final TypeDefinitionBuilder tdb) {
+ throw new YangParseException(line, "Can not set type to " + NAME);
}
@Override
public void setPath(final SchemaPath schemaPath) {
- throw new IllegalStateException("Can not set path to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set path to " + NAME);
}
@Override
public void setDescription(final String description) {
- throw new IllegalStateException("Can not set description to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set description to " + NAME);
}
@Override
public void setReference(final String reference) {
- throw new IllegalStateException("Can not set reference to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set reference to " + NAME);
}
@Override
public void setStatus(final Status status) {
- throw new IllegalStateException("Can not set status to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set status to " + NAME);
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return false;
+ }
+
+ @Override
+ public void setAddedByUses(final boolean addedByUses) {
+ throw new YangParseException(line, "Identityref type can not be added by uses.");
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownNodes() {
+ return Collections.emptyList();
}
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- throw new IllegalStateException("Can not add unknown node to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
+ throw new YangParseException(line, "Can not add unknown node to " + NAME);
}
@Override
@Override
public void setRanges(List<RangeConstraint> ranges) {
- throw new IllegalStateException("Can not set ranges to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set ranges to " + NAME);
}
@Override
@Override
public void setLengths(List<LengthConstraint> lengths) {
- throw new IllegalStateException("Can not set lengths to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set lengths to " + NAME);
}
@Override
@Override
public void setPatterns(List<PatternConstraint> patterns) {
- throw new IllegalStateException("Can not set patterns to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set patterns to " + NAME);
}
@Override
@Override
public void setFractionDigits(Integer fractionDigits) {
- throw new IllegalStateException("Can not set fraction digits to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set fraction digits to " + NAME);
}
@Override
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
return Collections.emptyList();
}
@Override
public void setDefaultValue(Object defaultValue) {
- throw new IllegalStateException("Can not set default value to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set default value to " + NAME);
}
@Override
@Override
public void setUnits(String units) {
- throw new IllegalStateException("Can not set units to "
- + IdentityrefTypeBuilder.class.getSimpleName());
+ throw new YangParseException(line, "Can not set units to " + NAME);
}
@Override
public String toString() {
- final StringBuilder result = new StringBuilder(
- IdentityrefTypeBuilder.class.getSimpleName() + "[");
+ final StringBuilder result = new StringBuilder(IdentityrefTypeBuilder.class.getSimpleName() + "[");
result.append(", base=" + baseQName);
result.append("]");
return result.toString();