use of org.kie.workbench.common.stunner.core.definition.property.PropertyMetaTypes in project kie-wb-common by kiegroup.
the class MainProcessor method processProperties.
private boolean processProperties(final Set<? extends TypeElement> set, final Element e, final RoundEnvironment roundEnv) throws Exception {
final boolean isClass = e.getKind() == ElementKind.CLASS;
if (isClass) {
TypeElement classElement = (TypeElement) e;
PackageElement packageElement = (PackageElement) classElement.getEnclosingElement();
String propertyClassName = packageElement.getQualifiedName().toString() + "." + classElement.getSimpleName();
// Meta-properties
Property metaProperty = e.getAnnotation(Property.class);
if (null != metaProperty) {
PropertyMetaTypes type = metaProperty.meta();
if (!PropertyMetaTypes.NONE.equals(type)) {
processingContext.getMetaPropertyTypes().put(type, propertyClassName + ".class");
}
}
// Value fields.
processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_VALUE, processingContext.getPropertyAnnotations().getValueFieldNames(), true);
// Allowed Values fields.
processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_ALLOWED_VALUES, processingContext.getPropertyAnnotations().getAllowedValuesFieldNames(), false);
// Caption fields.
processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_CAPTION, processingContext.getPropertyAnnotations().getCaptionFieldNames(), false);
// Description fields.
processFieldName(classElement, propertyClassName, ANNOTATION_DESCRIPTION, processingContext.getPropertyAnnotations().getDescriptionFieldNames(), false);
// Property Type field.
final boolean propTypeAnnFound = processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_TYPE, processingContext.getPropertyAnnotations().getTypeFieldNames(), false);
// the value object.
if (!propTypeAnnFound) {
Map<String, Element> fieldNames = getFieldNames(classElement, ANNOTATION_PROPERTY_VALUE);
if (!fieldNames.isEmpty()) {
final TypeElement te = (TypeElement) fieldNames.values().iterator().next();
final String type = te.getQualifiedName().toString();
final Class<?> typeClass = Class.forName(type);
final Class<? extends PropertyType> defaultPropertyType = DefinitionUtils.getDefaultPropertyType(typeClass);
if (null != defaultPropertyType) {
processingContext.getPropertyAnnotations().getTypes().put(propertyClassName, defaultPropertyType.getName());
} else {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "No property type specified for class " + propertyClassName, classElement);
}
}
}
// Read only fields.
processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_READONLY, processingContext.getPropertyAnnotations().getReadOnlyFieldNames(), false);
// Optional fields.
processFieldName(classElement, propertyClassName, ANNOTATION_PROPERTY_OPTIONAL, processingContext.getPropertyAnnotations().getOptionalFieldNames(), false);
}
return false;
}
Aggregations