use of org.opendaylight.mdsal.binding.model.api.Type in project controller by opendaylight.
the class RuntimeRegistratorTest method testHierarchy.
@Test
public void testHierarchy() {
final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
doReturn(QName.create(URI.create("urn:x"), "leaf-local-name")).when(leaf).getQName();
doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
doReturn(java.util.Optional.empty()).when(leaf).getDescription();
final StringTypeDefinition leafType = mock(StringTypeDefinition.class);
doReturn(java.util.Optional.empty()).when(leafType).getDefaultValue();
doReturn(leafType).when(leaf).getType();
final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
final Type mockedType = mock(Type.class);
doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
}
use of org.opendaylight.mdsal.binding.model.api.Type in project controller by opendaylight.
the class JavaAttribute method getOpenType.
@Override
public OpenType<?> getOpenType() {
final TypeDefinition<?> baseTypeDefinition = getBaseType(this.typeProviderWrapper, this.typeDefinition);
final Type baseType = this.typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition);
if (isArray()) {
return getArrayType();
} else if (isEnum()) {
return getEnumType(baseTypeDefinition);
} else if (isUnion()) {
return getCompositeTypeForUnion(baseTypeDefinition);
} else if (isDerivedType(baseType, getType())) {
return getCompositeType(baseType, baseTypeDefinition);
} else if (isIdentityRef()) {
return getCompositeTypeForIdentity();
}
return getSimpleType(getType());
}
use of org.opendaylight.mdsal.binding.model.api.Type in project controller by opendaylight.
the class TemplateFactory method getReturnType.
private static String getReturnType(final AttributeIfc attributeIfc) {
String returnType;
if (attributeIfc instanceof TypedAttribute) {
final Type type = ((TypedAttribute) attributeIfc).getType();
returnType = serializeType(type);
} else if (attributeIfc == VoidAttribute.getInstance()) {
return "void";
} else {
throw new UnsupportedOperationException("Attribute not supported: " + attributeIfc.getClass());
}
return returnType;
}
use of org.opendaylight.mdsal.binding.model.api.Type in project controller by opendaylight.
the class TemplateFactory method serializeType.
// FIXME: put into Type.toString
static String serializeType(final Type type, final boolean addWildcards) {
if (type instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) type;
final StringBuilder sb = new StringBuilder();
sb.append(parameterizedType.getRawType().getFullyQualifiedName());
sb.append(addWildcards ? "<? extends " : "<");
boolean first = true;
for (final Type parameter : parameterizedType.getActualTypeArguments()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(serializeType(parameter));
}
sb.append(">");
return sb.toString();
} else {
return type.getFullyQualifiedName();
}
}
use of org.opendaylight.mdsal.binding.model.api.Type in project controller by opendaylight.
the class ModuleMXBeanEntryTemplatesTest method mockJavaAttr.
public static JavaAttribute mockJavaAttr() {
final JavaAttribute attr = mock(JavaAttribute.class);
final Type typeA = mock(Type.class);
doReturn("package").when(typeA).getName();
doReturn("type").when(typeA).getPackageName();
doReturn("package.type").when(typeA).getFullyQualifiedName();
doReturn(typeA).when(attr).getType();
doReturn("Type").when(attr).getUpperCaseCammelCase();
doReturn("new Default()").when(attr).getNullableDefault();
return attr;
}
Aggregations