use of com.canoo.dp.impl.remoting.info.ClassInfo 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.ClassInfo 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);
}
}
use of com.canoo.dp.impl.remoting.info.ClassInfo in project dolphin-platform by canoo.
the class AbstractBeanBuilder method create.
public <T> T create(final Class<T> beanClass) {
final ClassInfo classInfo = classRepository.getOrCreateClassInfo(beanClass);
final PresentationModel model = buildPresentationModel(classInfo);
return createInstanceForClass(classInfo, beanClass, model, UpdateSource.SELF);
}
use of com.canoo.dp.impl.remoting.info.ClassInfo in project dolphin-platform by canoo.
the class ClassRepositoryImpl method getOrCreateClassInfo.
@Override
public ClassInfo getOrCreateClassInfo(final Class<?> beanClass) {
final ClassInfo existingClassInfo = classToClassInfoMap.get(beanClass);
if (existingClassInfo != null) {
return existingClassInfo;
}
createPresentationModelForClass(beanClass);
return classToClassInfoMap.get(beanClass);
}
Aggregations