Search in sources :

Example 1 with Enabled

use of com.manydesigns.elements.annotations.Enabled in project Portofino by ManyDesigns.

the class FormBuilder method configReflectiveFields.

public FormBuilder configReflectiveFields() {
    logger.debug("configReflectiveFields");
    groupedPropertyAccessors = new ArrayList<ArrayList<PropertyAccessor>>();
    fieldSetNames = new ArrayList<String>();
    ArrayList<PropertyAccessor> currentGroup = null;
    String currentGroupName = null;
    for (PropertyAccessor current : classAccessor.getProperties()) {
        // check if field is enabled
        Enabled enabled = current.getAnnotation(Enabled.class);
        if (enabled != null && !enabled.value()) {
            logger.debug("Skipping non-enabled field: {}", current.getName());
            continue;
        }
        String groupName = null;
        if (current.isAnnotationPresent(com.manydesigns.elements.annotations.FieldSet.class)) {
            groupName = getText(current.getAnnotation(FieldSet.class).value());
        }
        if ((currentGroup == null) || (groupName != null && !groupName.equals(currentGroupName))) {
            currentGroup = new ArrayList<PropertyAccessor>();
            groupedPropertyAccessors.add(currentGroup);
            fieldSetNames.add(groupName);
            currentGroupName = groupName;
        }
        currentGroup.add(current);
    }
    logger.debug("configReflectiveFields");
    return this;
}
Also used : FieldSet(com.manydesigns.elements.annotations.FieldSet) PropertyAccessor(com.manydesigns.elements.reflection.PropertyAccessor) Enabled(com.manydesigns.elements.annotations.Enabled)

Aggregations

Enabled (com.manydesigns.elements.annotations.Enabled)1 FieldSet (com.manydesigns.elements.annotations.FieldSet)1 PropertyAccessor (com.manydesigns.elements.reflection.PropertyAccessor)1