use of org.apache.sling.caconfig.annotation.Property in project sling by apache.
the class AnnotationClassParser method buildPropertyMetadata.
@SuppressWarnings("unchecked")
private static <T> PropertyMetadata<T> buildPropertyMetadata(Method propertyMethod, Class<T> type) {
String propertyName = getPropertyName(propertyMethod.getName());
PropertyMetadata<?> propertyMetadata;
if (type.isArray() && type.getComponentType().isAnnotation()) {
ConfigurationMetadata nestedConfigMetadata = buildConfigurationMetadata_Nested(type.getComponentType(), propertyName, true);
propertyMetadata = new PropertyMetadata<>(propertyName, ConfigurationMetadata[].class).configurationMetadata(nestedConfigMetadata);
} else if (type.isAnnotation()) {
ConfigurationMetadata nestedConfigMetadata = buildConfigurationMetadata_Nested(type, propertyName, false);
propertyMetadata = new PropertyMetadata<>(propertyName, ConfigurationMetadata.class).configurationMetadata(nestedConfigMetadata);
} else {
propertyMetadata = new PropertyMetadata<>(propertyName, type).defaultValue((T) propertyMethod.getDefaultValue());
}
Property propertyAnnotation = propertyMethod.getAnnotation(Property.class);
if (propertyAnnotation != null) {
propertyMetadata.label(emptyToNull(propertyAnnotation.label())).description(emptyToNull(propertyAnnotation.description())).properties(propsArrayToMap(propertyAnnotation.property())).order(propertyAnnotation.order());
} else {
Map<String, String> emptyMap = Collections.emptyMap();
propertyMetadata.properties(emptyMap);
}
return (PropertyMetadata) propertyMetadata;
}
Aggregations