use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class FieldManagerTest method testGetFieldByTypeInfo.
@Test
public void testGetFieldByTypeInfo() {
for (Class clazz : basicTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
checkFieldExists(typeInfo);
}
for (Class clazz : basicMultipleTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(TypeKind.BASE, clazz.getName(), true);
checkFieldExists(typeInfo);
}
// check nested form
checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), false));
// check multiple subform
checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), true));
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class ModelPropertiesGenerator method createModelProperty.
public static ModelProperty createModelProperty(String name, String className, boolean isMultiple, ClassLoader classLoader) {
if (FormModelPropertiesUtil.isBaseType(className)) {
// Dealing with basic type properties (String, Integer...)
return new ModelPropertyImpl(name, new TypeInfoImpl(className, isMultiple));
} else {
// Dealing with complex types.
if (FormModelPropertiesUtil.isListType(className)) {
// If className is a List let's create a model for Object...
return createModelProperty(name, Object.class.getName(), true);
}
try {
Class clazz = classLoader.loadClass(className);
TypeKind typeKind = clazz.isEnum() ? TypeKind.ENUM : TypeKind.OBJECT;
return new ModelPropertyImpl(name, new TypeInfoImpl(typeKind, className, isMultiple));
} catch (ClassNotFoundException e) {
logger.warn("Unable to create property '" + name + "' for class '" + className + "':", e);
}
}
return null;
}
Aggregations