}
return null;
}
private static Property propertyFromField(final Field field, final PluginProperty annotation) {
final PropertyBuilder pbuild = PropertyBuilder.builder();
//determine type
final Property.Type type = propertyTypeFromFieldType(field.getType());
if (null == type) {
return null;
}
pbuild.type(type);
if (type == Property.Type.String) {
StringRenderingConstants.DisplayType renderBehaviour = StringRenderingConstants.DisplayType.SINGLE_LINE;
//set select/freeselect
final SelectValues selectAnnotation = field.getAnnotation(SelectValues.class);
if (null != selectAnnotation) {
pbuild.type(selectAnnotation.freeSelect() ? Property.Type.FreeSelect : Property.Type.Select);
pbuild.values(selectAnnotation.values());
}
if (field.getAnnotation(TextArea.class) != null) {
renderBehaviour = StringRenderingConstants.DisplayType.MULTI_LINE;
}
if (field.getAnnotation(Password.class) != null) {
renderBehaviour = StringRenderingConstants.DisplayType.PASSWORD;
}
pbuild.renderingOption(StringRenderingConstants.DISPLAY_TYPE_KEY, renderBehaviour);
}
String name = annotation.name();
if (null == name || "".equals(name)) {
name = field.getName();
}
pbuild.name(name);
if (null != annotation.title() && !"".equals(annotation.title())) {
pbuild.title(annotation.title());
} else {
pbuild.title(name);
}
pbuild.description(annotation.description());
if (null != annotation.defaultValue() && !"".equals(annotation.defaultValue())) {
pbuild.defaultValue(annotation.defaultValue());
}
pbuild.required(annotation.required());
pbuild.scope(annotation.scope());
return pbuild.build();
}