use of org.apache.tapestry5.beaneditor.ReorderProperties in project tapestry-5 by apache.
the class BeanModelSourceImpl method create.
public <T> BeanModel<T> create(Class<T> beanClass, boolean filterReadOnlyProperties, Messages messages) {
assert beanClass != null;
assert messages != null;
ClassPropertyAdapter adapter = propertyAccess.getAdapter(beanClass);
BeanModel<T> model = new BeanModelImpl<T>(beanClass, propertyConduitSource, typeCoercer, messages, locator);
for (final String propertyName : adapter.getPropertyNames()) {
PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);
if (!pa.isRead()) {
continue;
}
if (isStaticFieldProperty(pa)) {
continue;
}
if (pa.getAnnotation(NonVisual.class) != null) {
continue;
}
if (filterReadOnlyProperties && !pa.isUpdate()) {
continue;
}
final String dataType = dataTypeAnalyzer.identifyDataType(pa);
if (dataType == null) {
continue;
}
model.add(propertyName).dataType(dataType);
}
// First, order the properties based on the location of the getter method
// within the class.
List<String> propertyNames = model.getPropertyNames();
orderProperties(adapter, propertyNames);
model.reorder(propertyNames.toArray(new String[propertyNames.size()]));
// Next, check for an annotation with specific ordering information.
ReorderProperties reorderAnnotation = beanClass.getAnnotation(ReorderProperties.class);
if (reorderAnnotation != null) {
BeanModelUtils.reorder(model, reorderAnnotation.value());
}
return model;
}
Aggregations