Example usage for javax.lang.model.element TypeElement toString

List of usage examples for javax.lang.model.element TypeElement toString

Introduction

In this page you can find the example usage for javax.lang.model.element TypeElement toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.kie.workbench.common.stunner.core.processors.MainProcessor.java

private Map<String, Element> getFieldNames(TypeElement classElement, String annotation) {
    final Messager messager = processingEnv.getMessager();
    final Elements elementUtils = processingEnv.getElementUtils();
    Map<String, Element> result = new LinkedHashMap<>();
    while (!classElement.toString().equals(Object.class.getName())) {
        List<VariableElement> variableElements = ElementFilter.fieldsIn(classElement.getEnclosedElements());
        for (VariableElement variableElement : variableElements) {
            if (GeneratorUtils.getAnnotation(elementUtils, variableElement, annotation) != null) {
                final TypeMirror fieldReturnType = variableElement.asType();
                final TypeElement t = (TypeElement) ((DeclaredType) fieldReturnType).asElement();
                final String fieldReturnTypeName = GeneratorUtils.getTypeMirrorDeclaredName(fieldReturnType);
                final String fieldName = variableElement.getSimpleName().toString();
                result.put(fieldName, t);
                messager.printMessage(Diagnostic.Kind.NOTE,
                        "Discovered property value " + "for class [" + classElement.getSimpleName() + "] "
                                + "at field [" + fieldName + "] " + "of return type [" + fieldReturnTypeName
                                + "]");
            }/*w  w w  .j  av  a2s.c  o m*/
        }
        classElement = getParent(classElement);
    }
    return result;
}