import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.EnumerationType;
import org.opendaylight.yangtools.yang.model.util.ExtendedType;
import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.model.util.StringType;
import org.opendaylight.yangtools.yang.model.util.UnionType;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.util.type.CompatUtils;
import org.opendaylight.yangtools.yang.parser.util.YangValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static boolean leafContainsEnumDefinition(final SchemaNode dataNode) {
if (dataNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
- if (leaf.getType() instanceof EnumTypeDefinition) {
+ if (CompatUtils.compatLeafType(leaf) instanceof EnumTypeDefinition) {
return true;
}
}
if (dataNode != null) {
if (dataNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
- returnType = javaTypeForSchemaDefinitionType(leaf.getType(), leaf);
+ returnType = javaTypeForSchemaDefinitionType(CompatUtils.compatLeafType(leaf), leaf);
} else if (dataNode instanceof LeafListSchemaNode) {
final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode;
returnType = javaTypeForSchemaDefinitionType(leafList.getType(), leafList);
}
public String getTypeDefaultConstruction(final LeafSchemaNode node, final String defaultValue) {
- TypeDefinition<?> type = node.getType();
+ TypeDefinition<?> type = CompatUtils.compatLeafType(node);
QName typeQName = type.getQName();
TypeDefinition<?> base = baseTypeDefForExtendedType(type);
Preconditions.checkNotNull(type, "Cannot provide default construction for null type of %s", node);
parentName = BindingMapping.getClassName(parent.getName());
className = packageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
}
- result = bitsToDef((BitsTypeDefinition) base, className, defaultValue, type instanceof ExtendedType);
+ result = bitsToDef((BitsTypeDefinition) base, className, defaultValue, type.getBaseType() != null);
} else if (base instanceof BooleanTypeDefinition) {
result = typeToDef(Boolean.class, defaultValue);
} else if (base instanceof DecimalTypeDefinition) {
defValArray[0] = first;
String newDefVal = new String(defValArray);
String className;
- if (type instanceof ExtendedType) {
+ if (type.getBaseType() != null) {
Module m = getParentModule(type);
String basePackageName = BindingMapping.getRootPackageName(m.getQNameModule());
String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, type.getPath());
}
sb.append(result);
- if (type instanceof ExtendedType && !(base instanceof LeafrefTypeDefinition)
- && !(base instanceof EnumerationType) && !(base instanceof UnionTypeDefinition)) {
+ if (type.getBaseType() != null && !(base instanceof LeafrefTypeDefinition)
+ && !(base instanceof EnumTypeDefinition) && !(base instanceof UnionTypeDefinition)) {
Module m = getParentModule(type);
String basePackageName = BindingMapping.getRootPackageName(m.getQNameModule());
String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, type.getPath());
}
private String unionToDef(final LeafSchemaNode node) {
+ final TypeDefinition<?> type = CompatUtils.compatLeafType(node);
String parentName;
String className;
- if (node.getType() instanceof ExtendedType) {
- ExtendedType type = (ExtendedType) node.getType();
+ if (type.getBaseType() != null) {
QName typeQName = type.getQName();
Module module = null;
Set<Module> modules = schemaContext.findModuleByNamespace(typeQName.getNamespace());