use of org.kie.workbench.common.stunner.core.definition.annotation.property.Type in project kie-wb-common by kiegroup.
the class BackendPropertyAdapter method getType.
@Override
public PropertyType getType(final T property) {
PropertyType pType = null;
try {
pType = getAnnotatedFieldValue(property, Type.class);
// If no type found from annotations, try to figure it out given the class for the value instance.
if (null == pType) {
final Collection<Field> valueFields = ReflectionAdapterUtils.getFieldAnnotations(property.getClass(), Value.class);
if (null != valueFields && !valueFields.isEmpty()) {
final Class<?> valueType = valueFields.iterator().next().getType();
final Class<? extends PropertyType> defaultPropertyType = DefinitionUtils.getDefaultPropertyType(valueType);
if (null != defaultPropertyType) {
pType = defaultPropertyType.newInstance();
}
}
}
} catch (Exception e) {
LOG.error("Error obtaining annotated category for Property with id " + getId(property));
}
if (null == pType) {
LOG.error("No property type specified for Property with id " + getId(property));
}
return pType;
}
Aggregations