List of usage examples for javax.lang.model.type MirroredTypeException getTypeMirror
public TypeMirror getTypeMirror()
From source file:com.github.hackersun.processor.factory.FactoryAnnotatedClass.java
/** * @throws ProcessingException if id() from annotation is null *//* w w w . j ava 2s .c om*/ public FactoryAnnotatedClass(TypeElement classElement) throws ProcessingException { this.annotatedClassElement = classElement; Factory annotation = classElement.getAnnotation(Factory.class); id = annotation.id(); if (StringUtils.isEmpty(id)) { throw new ProcessingException(classElement, "id() in @%s for class %s is null or empty! that's not allowed", Factory.class.getSimpleName(), classElement.getQualifiedName().toString()); } // Get the full QualifiedTypeName try { Class<?> clazz = annotation.type(); qualifiedGroupClassName = clazz.getCanonicalName(); simpleFactoryGroupName = clazz.getSimpleName(); } catch (MirroredTypeException mte) { DeclaredType classTypeMirror = (DeclaredType) mte.getTypeMirror(); TypeElement classTypeElement = (TypeElement) classTypeMirror.asElement(); qualifiedGroupClassName = classTypeElement.getQualifiedName().toString(); simpleFactoryGroupName = classTypeElement.getSimpleName().toString(); } }
From source file:org.squashtest.tm.tools.annotation.processor.DynamicComponentProcessor.java
private TypeMirror extractEntityClass(ANNOTATION definition) { // explanations for the following turd : // http://blog.retep.org/2009/02/13/getting-class-values-from-annotations-in-an-annotationprocessor/ TypeMirror entityClass = null; try {//from w w w. j a v a 2s. c o m entityClass(definition); } catch (MirroredTypeException e) { entityClass = e.getTypeMirror(); } return entityClass; }
From source file:easymvp.compiler.EasyMVPProcessor.java
private TypeElement getTypeElement(MirroredTypeException mte) { DeclaredType declaredType = (DeclaredType) mte.getTypeMirror(); return (TypeElement) declaredType.asElement(); }
From source file:org.shredzone.commons.taglib.processor.TaglibProcessor.java
/** * Processes a {@link Tag} annotation./*ww w . ja v a2s . co m*/ * * @param element * Program element with that tag */ private void processTag(Element element) { Tag tagAnno = element.getAnnotation(Tag.class); String className = element.toString(); String tagName = computeTagName(tagAnno.name(), className); // Try to evaluate the class name of the tag type String tagTypeClass = null; try { Class<? extends JspTag> tagType = tagAnno.type(); tagTypeClass = tagType.getName(); } catch (MirroredTypeException ex) { // This is a hack, see http://forums.sun.com/thread.jspa?threadID=791053 tagTypeClass = ex.getTypeMirror().toString(); } if (!PROXY_MAP.containsKey(tagTypeClass)) { throw new ProcessorException("No proxy for tag type " + tagTypeClass); } TagBean tag = new TagBean(tagName, className, tagAnno.bodycontent(), tagTypeClass); tag.setProxyClassName(className + "Proxy"); if (StringUtils.hasText(tagAnno.bean())) { tag.setBeanName(tagAnno.bean()); } else { tag.setBeanName(StringUtils.uncapitalize(StringUtils.unqualify(className))); } tag.setTryCatchFinally(tagAnno.tryCatchFinally()); taglib.addTag(tag); }
From source file:org.kie.workbench.common.forms.adf.processors.FormDefinitionGenerator.java
private List<FormDefinitionFieldData> extracFormFields(TypeElement type, FieldPolicy policy, I18nSettings i18nSettings, Map<String, String> defaultParams) throws Exception { final Types typeUtils = context.getProcessingEnvironment().getTypeUtils(); Collection<FieldInfo> fieldInfos = FormGenerationUtils.extractFieldInfos(type, fieldElement -> filter(fieldElement, policy)); List<FormDefinitionFieldData> fieldSettings = new ArrayList<>(); for (FieldInfo fieldInfo : fieldInfos) { if (fieldInfo.getSetter() != null && fieldInfo.getGetter() != null) { String fieldName = fieldInfo.getFieldElement().getSimpleName().toString(); FormDefinitionFieldData fieldData = new FormDefinitionFieldData(type.getQualifiedName().toString(), fieldName);/*from w w w.j a v a 2s. co m*/ fieldData.setLabel(fieldName); fieldData.setBinding(fieldName); fieldData.setMethodName("getFormElement_" + fieldName); boolean isList = false; org.kie.workbench.common.forms.model.TypeKind typeKind = org.kie.workbench.common.forms.model.TypeKind.BASE; boolean overrideI18n = false; TypeMirror finalType = fieldInfo.getFieldElement().asType(); TypeElement finalTypeElement = (TypeElement) typeUtils.asElement(finalType); String fieldModifier = ""; if (finalTypeElement.getKind().equals(ElementKind.CLASS)) { FieldDefinition fieldDefinitionAnnotation = finalTypeElement .getAnnotation(FieldDefinition.class); if (fieldDefinitionAnnotation != null) { // Override the using the i18n mechanism if (fieldDefinitionAnnotation.i18nMode().equals(I18nMode.OVERRIDE_I18N_KEY)) { fieldData.setLabel(finalType.toString() + i18nSettings.separator() + fieldDefinitionAnnotation.labelKeySuffix()); Collection<FieldInfo> labelInfos = FormGenerationUtils.extractFieldInfos( finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldLabel.class) != null); if (labelInfos != null && labelInfos.size() == 1) { FieldInfo labelInfo = labelInfos.iterator().next(); fieldData.setLabel(finalType.toString() + i18nSettings.separator() + labelInfo.getFieldElement().getSimpleName()); } fieldData.setHelpMessage(finalType.toString() + i18nSettings.separator() + fieldDefinitionAnnotation.helpMessageKeySuffix()); Collection<FieldInfo> helpMessages = FormGenerationUtils.extractFieldInfos( finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldHelp.class) != null); if (helpMessages != null && helpMessages.size() == 1) { FieldInfo helpInfo = helpMessages.iterator().next(); fieldData.setHelpMessage(finalType.toString() + i18nSettings.separator() + helpInfo.getFieldElement().getSimpleName()); } } Collection<FieldInfo> fieldValue = FormGenerationUtils.extractFieldInfos(finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldValue.class) != null); if (fieldValue == null || fieldValue.size() != 1) { throw new Exception("Problem processing FieldDefinition [" + finalType + "]: it should have one field marked as @FieldValue"); } FieldInfo valueInfo = fieldValue.iterator().next(); fieldData.setBinding( fieldData.getBinding() + "." + valueInfo.getFieldElement().getSimpleName()); fieldModifier = FormGenerationUtils.fixClassName(finalType.toString()) + "_FieldStatusModifier"; finalType = valueInfo.getFieldElement().asType(); finalTypeElement = (TypeElement) typeUtils.asElement(finalType); overrideI18n = !fieldDefinitionAnnotation.i18nMode().equals(I18nMode.DONT_OVERRIDE); } else { FormDefinition formDefinitionAnnotation = finalTypeElement .getAnnotation(FormDefinition.class); if (formDefinitionAnnotation != null) { fieldData.setLabel( finalType.toString() + i18nSettings.separator() + FieldDefinition.LABEL); Collection<FieldInfo> labelInfos = FormGenerationUtils.extractFieldInfos( finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldLabel.class) != null); if (labelInfos != null && labelInfos.size() == 1) { FieldInfo labelInfo = labelInfos.iterator().next(); fieldData.setLabel(finalType.toString() + i18nSettings.separator() + labelInfo.getFieldElement().getSimpleName()); overrideI18n = true; } fieldData.setHelpMessage( finalType.toString() + i18nSettings.separator() + FieldDefinition.HELP_MESSAGE); Collection<FieldInfo> helpMessages = FormGenerationUtils.extractFieldInfos( finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldHelp.class) != null); if (helpMessages != null && helpMessages.size() == 1) { FieldInfo helpInfo = helpMessages.iterator().next(); fieldData.setHelpMessage(finalType.toString() + i18nSettings.separator() + helpInfo.getFieldElement().getSimpleName()); overrideI18n = true; } typeKind = org.kie.workbench.common.forms.model.TypeKind.OBJECT; } } } DeclaredType fieldType = (DeclaredType) finalType; if (typeUtils.isAssignable(finalTypeElement.asType(), listType)) { if (fieldType.getTypeArguments().size() != 1) { throw new IllegalArgumentException("Impossible to generate a field for type " + fieldType.toString() + ". Type should have one and only one Type arguments."); } isList = true; finalType = fieldType.getTypeArguments().get(0); finalTypeElement = (TypeElement) typeUtils.asElement(finalType); if (FormModelPropertiesUtil.isBaseType(finalTypeElement.getQualifiedName().toString())) { typeKind = org.kie.workbench.common.forms.model.TypeKind.BASE; } else if (typeUtils.isAssignable(finalTypeElement.asType(), enumType)) { typeKind = org.kie.workbench.common.forms.model.TypeKind.ENUM; } else { typeKind = org.kie.workbench.common.forms.model.TypeKind.OBJECT; } } else if (typeUtils.isAssignable(finalTypeElement.asType(), enumType)) { typeKind = org.kie.workbench.common.forms.model.TypeKind.ENUM; } fieldData.setType(typeKind.toString()); fieldData.setClassName(finalTypeElement.getQualifiedName().toString()); fieldData.setList(String.valueOf(isList)); fieldData.setFieldModifier(fieldModifier); fieldData.getParams().putAll(defaultParams); FormField settings = fieldInfo.getFieldElement().getAnnotation(FormField.class); if (settings != null) { try { fieldData.setPreferredType(settings.type().getName()); } catch (MirroredTypeException exception) { fieldData.setPreferredType(exception.getTypeMirror().toString()); } fieldData.setAfterElement(settings.afterElement()); if (!overrideI18n && !isEmpty(settings.labelKey())) { fieldData.setLabel(settings.labelKey()); } if (!overrideI18n && !isEmpty(settings.helpMessageKey())) { fieldData.setHelpMessage(settings.helpMessageKey()); } fieldData.setRequired(Boolean.valueOf(settings.required()).toString()); fieldData.setReadOnly(Boolean.valueOf(settings.readonly()).toString()); for (FieldParam fieldParam : settings.settings()) { fieldData.getParams().put(fieldParam.name(), fieldParam.value()); } fieldData.setWrap(Boolean.valueOf(settings.layoutSettings().wrap()).toString()); fieldData.setHorizontalSpan(String.valueOf(settings.layoutSettings().horizontalSpan())); fieldData.setVerticalSpan(String.valueOf(settings.layoutSettings().verticalSpan())); } if (!overrideI18n) { if (!isEmpty(i18nSettings.keyPreffix())) { fieldData.setLabel( i18nSettings.keyPreffix() + i18nSettings.separator() + fieldData.getLabel()); if (!isEmpty(fieldData.getHelpMessage())) { fieldData.setHelpMessage(i18nSettings.keyPreffix() + i18nSettings.separator() + fieldData.getHelpMessage()); } } } extractFieldExtraSettings(fieldData, fieldInfo.getFieldElement()); fieldSettings.add(fieldData); } } return fieldSettings; }
From source file:org.kie.workbench.common.forms.adf.processors.FormDefinitionsProcessor.java
private List<Map<String, String>> extracFormFields(TypeElement type, FieldPolicy policy, I18nSettings i18nSettings) throws Exception { final Elements elementUtils = processingEnv.getElementUtils(); Collection<FieldInfo> fieldInfos = extractFieldInfos(type, fieldElement -> { if (policy.equals(FieldPolicy.ALL)) { AnnotationMirror annotation = GeneratorUtils.getAnnotation(elementUtils, fieldElement, SkipFormField.class.getName()); if (annotation != null) { return false; }/*from w w w. ja v a2 s. co m*/ } else { AnnotationMirror annotation = GeneratorUtils.getAnnotation(elementUtils, fieldElement, FormField.class.getName()); if (annotation == null) { return false; } } return true; }); List<Map<String, String>> elementsSettings = new ArrayList<>(); for (FieldInfo fieldInfo : fieldInfos) { if (fieldInfo.getter != null && fieldInfo.setter != null) { String fieldName = fieldInfo.fieldElement.getSimpleName().toString(); String fieldLabel = fieldName; String binding = fieldName; String methodName = "getFormElement_" + fieldName; Map<String, Object> elementContext = new HashMap<>(); boolean isList = false; org.kie.workbench.common.forms.model.TypeKind typeKind = org.kie.workbench.common.forms.model.TypeKind.BASE; boolean overrideI18nLabel = false; TypeMirror finalType = fieldInfo.fieldElement.asType(); String fieldModifier = ""; if (finalType instanceof DeclaredType) { Element finalTypeElement = processingEnv.getTypeUtils().asElement(finalType); if (finalTypeElement.getKind().equals(ElementKind.CLASS)) { FieldDefinition fieldDefinitionAnnotation = finalTypeElement .getAnnotation(FieldDefinition.class); if (fieldDefinitionAnnotation != null) { // Override the using the i18n mechanism if (fieldDefinitionAnnotation.labelMode().equals(LabelMode.OVERRIDE_I18N_KEY)) { Collection<FieldInfo> labelInfos = extractFieldInfos((TypeElement) finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldLabel.class) != null); if (labelInfos == null || labelInfos.size() != 1) { throw new Exception("Problem processing FieldDefinition [" + finalType + "]: it should have one field marked as @FieldLabel"); } FieldInfo labelInfo = labelInfos.iterator().next(); fieldLabel = finalType.toString() + i18nSettings.separator() + labelInfo.fieldElement.getSimpleName(); } Collection<FieldInfo> fieldValue = extractFieldInfos((TypeElement) finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldValue.class) != null); if (fieldValue == null || fieldValue.size() != 1) { throw new Exception("Problem processing FieldDefinition [" + finalType + "]: it should have one field marked as @FieldValue"); } FieldInfo valueInfo = fieldValue.iterator().next(); binding += "." + valueInfo.getFieldElement().getSimpleName(); fieldModifier = fixClassName(finalType.toString()) + "_FieldStatusModifier"; finalType = valueInfo.getFieldElement().asType(); overrideI18nLabel = !fieldDefinitionAnnotation.labelMode() .equals(LabelMode.DONT_OVERRIDE); } else { FormDefinition formDefinitionAnnotation = finalTypeElement .getAnnotation(FormDefinition.class); if (formDefinitionAnnotation != null) { Collection<FieldInfo> labelInfos = extractFieldInfos((TypeElement) finalTypeElement, fieldElement -> fieldElement.getAnnotation(FieldLabel.class) != null); if (labelInfos != null & labelInfos.size() == 1) { FieldInfo labelInfo = labelInfos.iterator().next(); fieldLabel = finalType.toString() + i18nSettings.separator() + labelInfo.fieldElement.getSimpleName(); overrideI18nLabel = true; } typeKind = org.kie.workbench.common.forms.model.TypeKind.OBJECT; } } } DeclaredType fieldType = (DeclaredType) finalType; if (processingEnv.getTypeUtils().isAssignable(fieldType.asElement().asType(), listType)) { if (fieldType.getTypeArguments().size() != 1) { throw new IllegalArgumentException("Impossible to generate a field for type " + fieldType.toString() + ". Type should have one and only one Type arguments."); } isList = true; finalType = fieldType.getTypeArguments().get(0); typeKind = org.kie.workbench.common.forms.model.TypeKind.OBJECT; } else if (elementUtils.getTypeElement(finalType.toString()).getSuperclass().toString() .startsWith("java.lang.Enum")) { typeKind = org.kie.workbench.common.forms.model.TypeKind.ENUM; } } elementContext.put("formModel", type.getQualifiedName().toString()); elementContext.put("methodName", methodName); elementContext.put("fieldName", fieldName); elementContext.put("binding", binding); elementContext.put("type", typeKind.toString()); elementContext.put("className", finalType.toString()); elementContext.put("isList", String.valueOf(isList)); elementContext.put("fieldModifier", fieldModifier); Map<String, String> params = new HashMap<>(); elementContext.put("params", params); String afterElement = ""; FormField settings = fieldInfo.fieldElement.getAnnotation(FormField.class); if (settings != null) { String typeName; try { typeName = settings.type().getName(); } catch (MirroredTypeException exception) { typeName = exception.getTypeMirror().toString(); } if (StringUtils.isEmpty(typeName)) { typeName = FieldType.class.getName(); } afterElement = settings.afterElement(); elementContext.put("preferredType", typeName); if (!overrideI18nLabel) { fieldLabel = settings.labelKey(); } elementContext.put("required", Boolean.valueOf(settings.required()).toString()); elementContext.put("readOnly", Boolean.valueOf(settings.readonly()).toString()); for (FieldParam fieldParam : settings.settings()) { params.put(fieldParam.name(), fieldParam.value()); } elementContext.put("wrap", Boolean.valueOf(settings.layoutSettings().wrap()).toString()); elementContext.put("horizontalSpan", String.valueOf(settings.layoutSettings().horizontalSpan())); elementContext.put("verticalSpan", String.valueOf(settings.layoutSettings().verticalSpan())); } else { elementContext.put("preferredType", FieldType.class.getName()); elementContext.put("required", Boolean.FALSE.toString()); elementContext.put("readOnly", Boolean.FALSE.toString()); elementContext.put("wrap", Boolean.FALSE.toString()); elementContext.put("horizontalSpan", "1"); elementContext.put("verticalSpan", "1"); } if (!overrideI18nLabel) { if (!StringUtils.isEmpty(i18nSettings.keyPreffix())) { fieldLabel = i18nSettings.keyPreffix() + i18nSettings.separator() + fieldLabel; } } elementContext.put("labelKey", fieldLabel); elementContext.put("afterElement", afterElement); extractFieldExtraSettings(elementContext, fieldInfo.fieldElement); StringBuffer methodCode = writeTemplate("templates/FieldElement.ftl", elementContext); Map<String, String> fieldSettings = new HashMap<>(); fieldSettings.put("elementName", fieldName); fieldSettings.put("afterElement", afterElement); fieldSettings.put("methodName", methodName); fieldSettings.put("method", methodCode.toString()); elementsSettings.add(fieldSettings); } } return elementsSettings; }
From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java
private void processDefinitionModelBuilder(final Element e, final String className, final Map<String, String> processingContextMap) { Definition definitionAnn = e.getAnnotation(Definition.class); TypeMirror bMirror = null;/*from w ww .j a v a 2 s . co m*/ try { Class<?> builderClass = definitionAnn.builder(); } catch (MirroredTypeException mte) { bMirror = mte.getTypeMirror(); } if (null != bMirror && !VoidBuilder.class.getName().equals(bMirror.toString())) { String fqcn = bMirror.toString(); processingContextMap.put(className, fqcn); } }
From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java
private void processDefinitionSetModelBuilder(final Element e, final String className, final Map<String, String> processingContextMap) { DefinitionSet definitionAnn = e.getAnnotation(DefinitionSet.class); TypeMirror bMirror = null;/*from www .j a v a 2 s . c o m*/ try { Class<?> builderClass = definitionAnn.builder(); } catch (MirroredTypeException mte) { bMirror = mte.getTypeMirror(); } if (null != bMirror && !VoidBuilder.class.getName().equals(bMirror.toString())) { String fqcn = bMirror.toString(); processingContextMap.put(className, fqcn); } }
From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java
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 { Class<?> defaultTypeClass = morphBaseAnn.binder(); } catch (MirroredTypeException mte) { morphDefaultTypeMirror = mte.getTypeMirror(); }/*from w ww .jav a 2s .co m*/ if (null == morphDefaultTypeMirror) { throw new RuntimeException("No binder class specifyed for the @MorphProperty."); } String binderClassName = morphDefaultTypeMirror.toString(); ProcessingMorphProperty morphProperty = new ProcessingMorphProperty(fieldReturnTypeName, StringUtils.capitalize(fieldName), binderClassName); List<ProcessingMorphProperty> morphProperties = processingContext.getMorphingAnnotations() .getBaseMorphProperties().get(definitionClassName); if (null == morphProperties) { morphProperties = new LinkedList<>(); processingContext.getMorphingAnnotations().getBaseMorphProperties().put(definitionClassName, morphProperties); } morphProperties.add(morphProperty); } } }
From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java
private boolean processDefinitions(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 defintionClassName = packageElement.getQualifiedName().toString() + "." + classElement.getSimpleName(); Map<String, String> baseTypes = processingContext.getDefinitionAnnotations().getBaseTypes(); TypeElement parentElement = getDefinitionInheritedType(classElement); if (null != parentElement && !baseTypes.containsKey(defintionClassName)) { PackageElement basePackageElement = (PackageElement) parentElement.getEnclosingElement(); String baseClassName = basePackageElement.getQualifiedName().toString() + "." + parentElement.getSimpleName(); baseTypes.put(defintionClassName, baseClassName); }/*from ww w .ja va 2s. co m*/ // Category fields. processFieldName(classElement, defintionClassName, ANNOTATION_DEFINITION_CATEGORY, processingContext.getDefinitionAnnotations().getCategoryFieldNames(), true); // Title fields. processFieldName(classElement, defintionClassName, ANNOTATION_DEFINITION_TITLE, processingContext.getDefinitionAnnotations().getTitleFieldNames(), true); // Description fields. processFieldName(classElement, defintionClassName, ANNOTATION_DESCRIPTION, processingContext.getDefinitionAnnotations().getDescriptionFieldNames(), true); // Labels fields. processFieldName(classElement, defintionClassName, ANNOTATION_DEFINITION_LABELS, processingContext.getDefinitionAnnotations().getLabelsFieldNames(), true); // Builder class. processDefinitionModelBuilder(e, defintionClassName, processingContext.getDefinitionAnnotations().getBuilderFieldNames()); // Graph element. Definition definitionAnn = e.getAnnotation(Definition.class); TypeMirror mirror = null; try { Class<?> graphClass = definitionAnn.graphFactory(); } catch (MirroredTypeException mte) { mirror = mte.getTypeMirror(); } if (null == mirror) { throw new RuntimeException("No graph factory class specified for the @Definition."); } String fqcn = mirror.toString(); processingContext.getDefinitionAnnotations().getGraphFactoryFieldNames().put(defintionClassName, fqcn); // PropertySets fields. Map<String, Element> propertySetElements = getFieldNames(classElement, ANNOTATION_PROPERTY_SET); if (null != propertySetElements && !propertySetElements.isEmpty()) { processingContext.getPropertySetElements().addAll(propertySetElements.values()); processingContext.getDefinitionAnnotations().getPropertySetFieldNames().put(defintionClassName, new LinkedHashSet<>(propertySetElements.keySet())); } else { note("Definition for tye [" + defintionClassName + "] have no Property Set members."); } // Properties fields. Map<String, Element> propertyElements = getFieldNames(classElement, ANNOTATION_PROPERTY); if (null != propertyElements && !propertyElements.isEmpty()) { processingContext.getPropertyElements().addAll(propertyElements.values()); processingContext.getDefinitionAnnotations().getPropertyFieldNames().put(defintionClassName, new LinkedHashSet<>(propertyElements.keySet())); } else { note("Definition for tye [" + defintionClassName + "] have no Property members."); } // -- Morphing annotations -- MorphBase morphBaseAnn = e.getAnnotation(MorphBase.class); Morph morphAnn = e.getAnnotation(Morph.class); if (null != morphBaseAnn && null != morphAnn) { TypeElement superElement = getAnnotationInTypeInheritance(classElement, MorphBase.class.getName()); final String packageName = packageElement.getQualifiedName().toString(); String morphBaseClassName = packageName + "." + superElement.getSimpleName().toString(); Map<String, String> defaultTypesMap = processingContext.getMorphingAnnotations() .getBaseDefaultTypes(); if (null == defaultTypesMap.get(morphBaseClassName)) { TypeMirror morphDefaultTypeMirror = null; try { Class<?> defaultTypeClass = morphBaseAnn.defaultType(); } catch (MirroredTypeException mte) { morphDefaultTypeMirror = mte.getTypeMirror(); } if (null == morphDefaultTypeMirror) { throw new RuntimeException("No default type class specifyed for the @MorphBase."); } String morphDefaultTypeClassName = morphDefaultTypeMirror.toString(); processingContext.getMorphingAnnotations().getBaseDefaultTypes().put(morphBaseClassName, morphDefaultTypeClassName); // MorphBase - targets List<? extends TypeMirror> morphTargetMirrors = null; try { Class<?>[] defsClasses = morphBaseAnn.targets(); } catch (MirroredTypesException mte) { morphTargetMirrors = mte.getTypeMirrors(); } if (null != morphTargetMirrors) { Set<String> morphTargetMirrorClasses = new LinkedHashSet<>(); for (TypeMirror morphTargetMirror : morphTargetMirrors) { String morphTargetMirrorClassName = morphTargetMirror.toString(); morphTargetMirrorClasses.add(morphTargetMirrorClassName); } processingContext.getMorphingAnnotations().getBaseTargets().put(morphBaseClassName, morphTargetMirrorClasses); } // Morph Properties. processMorphProperties(superElement, morphBaseClassName); } TypeMirror morphBaseTypeMirror = null; try { Class<?> defaultTypeClass = morphAnn.base(); } catch (MirroredTypeException mte) { morphBaseTypeMirror = mte.getTypeMirror(); } if (null == morphBaseTypeMirror) { throw new RuntimeException("No base type class specifyed for the @MorphBase."); } String morphBaseTypeClassName = morphBaseTypeMirror.toString(); Set<String> currentTargets = processingContext.getMorphingAnnotations().getBaseTargets() .get(morphBaseTypeClassName); if (null == currentTargets) { currentTargets = new LinkedHashSet<>(); processingContext.getMorphingAnnotations().getBaseTargets().put(morphBaseTypeClassName, currentTargets); } currentTargets.add(defintionClassName); } } return false; }