use of org.kie.workbench.common.stunner.core.definition.annotation.morph.MorphProperty in project kie-wb-common by kiegroup.
the class MainProcessor method processMorphProperties.
private void processMorphProperties(final TypeElement classElement, final String definitionClassName) {
final Messager messager = processingEnv.getMessager();
final Elements elementUtils = processingEnv.getElementUtils();
List<VariableElement> variableElements = ElementFilter.fieldsIn(classElement.getEnclosedElements());
for (VariableElement variableElement : variableElements) {
if (GeneratorUtils.getAnnotation(elementUtils, variableElement, ANNOTATION_MORPH_PROPERTY) != null) {
final TypeMirror fieldReturnType = variableElement.asType();
final String fieldReturnTypeName = GeneratorUtils.getTypeMirrorDeclaredName(fieldReturnType);
final String fieldName = variableElement.getSimpleName().toString();
messager.printMessage(Diagnostic.Kind.NOTE, "Discovered Morph Property " + "for class [" + classElement.getSimpleName() + "] " + "at field [" + fieldName + "] " + "of return type [" + fieldReturnTypeName + "]");
// MorphBase - defaultType
MorphProperty morphBaseAnn = variableElement.getAnnotation(MorphProperty.class);
TypeMirror morphDefaultTypeMirror = null;
try {
morphBaseAnn.binder();
} catch (MirroredTypeException mte) {
morphDefaultTypeMirror = mte.getTypeMirror();
}
if (null == morphDefaultTypeMirror) {
throw new RuntimeException("No binder class declared for the @MorphProperty.");
}
String binderClassName = morphDefaultTypeMirror.toString();
ProcessingMorphProperty morphProperty = new ProcessingMorphProperty(fieldReturnTypeName, StringUtils.capitalize(fieldName), binderClassName);
List<ProcessingMorphProperty> morphProperties = processingContext.getMorphingAnnotations().getBaseMorphProperties().computeIfAbsent(definitionClassName, k -> new LinkedList<>());
morphProperties.add(morphProperty);
}
}
}
Aggregations