use of com.canoo.dp.impl.remoting.info.PropertyInfo in project dolphin-platform by canoo.
the class ClassRepositoryImpl method createClassInfoForClass.
private ClassInfo createClassInfoForClass(final Class<?> beanClass) {
final List<PropertyInfo> propertyInfos = new ArrayList<>();
final List<PropertyInfo> observableListInfos = new ArrayList<>();
for (Field field : ReflectionHelper.getInheritedDeclaredFields(beanClass)) {
PropertyType type = null;
if (Property.class.isAssignableFrom(field.getType())) {
type = PropertyType.PROPERTY;
} else if (ObservableList.class.isAssignableFrom(field.getType())) {
type = PropertyType.OBSERVABLE_LIST;
}
final Class<?> parameterType = ReflectionHelper.getTypeParameter(field);
if (type != null && parameterType != null) {
final String attributeName = DolphinUtils.getDolphinAttributePropertyNameForField(field);
final Converter converter = converters.getConverter(parameterType);
final PropertyInfo propertyInfo = new ClassPropertyInfo(attributeName, converter, field);
if (type == PropertyType.PROPERTY) {
propertyInfos.add(propertyInfo);
} else {
observableListInfos.add(propertyInfo);
}
}
}
return new ClassInfo(beanClass, propertyInfos, observableListInfos);
}
use of com.canoo.dp.impl.remoting.info.PropertyInfo in project dolphin-platform by canoo.
the class AbstractBeanBuilder method buildPresentationModel.
private PresentationModel buildPresentationModel(final ClassInfo classInfo) {
try {
Assert.requireNonNull(classInfo, "classInfo");
final PresentationModelBuilder builder = builderFactory.createBuilder().withType(classInfo.getModelType());
classInfo.forEachProperty(new ClassInfo.PropertyIterator() {
@Override
public void call(final PropertyInfo propertyInfo) {
Assert.requireNonNull(propertyInfo, "propertyInfo");
builder.withAttribute(propertyInfo.getAttributeName());
}
});
return builder.create();
} catch (Exception e) {
throw new DolphinRuntimeException("Cannot create presentation model for type " + classInfo.getBeanClass(), e);
}
}
Aggregations