use of com.haulmont.chile.core.datatypes.impl.EnumerationImpl in project cuba by cuba-platform.
the class EnumerationImplTest method testParseIntegerId.
@Test
public void testParseIntegerId() throws ParseException {
EnumerationImpl enumeration = new EnumerationImpl(PermissionType.class);
Enum enumValue = enumeration.parse("10");
Assert.assertEquals(PermissionType.SCREEN, enumValue);
}
use of com.haulmont.chile.core.datatypes.impl.EnumerationImpl in project cuba by cuba-platform.
the class EnumerationImplTest method testParseStringId.
@Test
public void testParseStringId() throws ParseException {
EnumerationImpl enumeration = new EnumerationImpl(FtsChangeType.class);
Enum enumValue = enumeration.parse("I");
Assert.assertEquals(FtsChangeType.INSERT, enumValue);
}
use of com.haulmont.chile.core.datatypes.impl.EnumerationImpl in project cuba by cuba-platform.
the class MetaModelLoader method loadRange.
protected MetadataObjectInfo<Range> loadRange(MetaProperty metaProperty, Class<?> type, Map<String, Object> map) {
Datatype datatype = (Datatype) map.get("datatype");
if (datatype != null) {
// A datatype is assigned explicitly
return new MetadataObjectInfo<>(new DatatypeRange(datatype));
}
datatype = getAdaptiveDatatype(metaProperty, type);
if (datatype == null) {
datatype = datatypes.get(type);
}
if (datatype != null) {
MetaClass metaClass = metaProperty.getDomain();
Class javaClass = metaClass.getJavaClass();
try {
String name = "get" + StringUtils.capitalize(metaProperty.getName());
Method method = javaClass.getMethod(name);
Class<Enum> returnType = (Class<Enum>) method.getReturnType();
if (returnType.isEnum()) {
return new MetadataObjectInfo<>(new EnumerationRange(new EnumerationImpl<>(returnType)));
}
} catch (NoSuchMethodException e) {
// ignore
}
return new MetadataObjectInfo<>(new DatatypeRange(datatype));
} else if (type.isEnum()) {
return new MetadataObjectInfo<>(new EnumerationRange(new EnumerationImpl(type)));
} else {
return new MetadataObjectInfo<>(null, Collections.singletonList(new RangeInitTask(metaProperty, type, map)));
}
}
use of com.haulmont.chile.core.datatypes.impl.EnumerationImpl in project cuba by cuba-platform.
the class EnumerationImplTest method testParseNonExistingId.
@Test
public void testParseNonExistingId() throws ParseException {
EnumerationImpl enumeration = new EnumerationImpl(FtsChangeType.class);
Enum enumValue = enumeration.parse("ZZZ");
Assert.assertNull(enumValue);
}
Aggregations