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

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.dspot.declex.action.Actions.java

private void createInformationForMethods(Element typeElement, ActionInfo actionInfo,
        List<String> methodsHandled) {

    if (methodsHandled == null) {
        methodsHandled = new LinkedList<>();
    }/*from  w ww.j a  v  a  2  s.  c o m*/

    for (Element elem : typeElement.getEnclosedElements()) {

        if (elem.getKind() == ElementKind.METHOD) {
            if (methodsHandled.contains(elem.toString()))
                continue;

            final ExecutableElement element = (ExecutableElement) elem;

            List<ActionMethodParam> params = new LinkedList<>();
            for (VariableElement param : element.getParameters()) {

                List<Annotation> annotations = new LinkedList<>();
                for (Class<? extends Annotation> annotation : ACTION_ANNOTATION) {
                    Annotation containedAnnotation = param.getAnnotation(annotation);
                    if (containedAnnotation != null) {
                        annotations.add(containedAnnotation);
                    }
                }

                final AbstractJClass paramType = codeModelHelper.elementTypeToJClass(param);

                ActionMethodParam actionMethodParam = new ActionMethodParam(param.getSimpleName().toString(),
                        paramType, annotations);
                params.add(actionMethodParam);
            }

            List<Annotation> annotations = new LinkedList<>();
            for (Class<? extends Annotation> annotation : ACTION_ANNOTATION) {
                Annotation containedAnnotation = element.getAnnotation(annotation);
                if (containedAnnotation != null) {
                    annotations.add(containedAnnotation);
                }
            }

            String javaDoc = env.getProcessingEnvironment().getElementUtils().getDocComment(element);

            final String clazz = element.getReturnType().toString();

            actionInfo.addMethod(element.getSimpleName().toString(), clazz, javaDoc, params, annotations);

            methodsHandled.add(element.toString());
        }
    }

    List<? extends TypeMirror> superTypes = env.getProcessingEnvironment().getTypeUtils()
            .directSupertypes(typeElement.asType());
    for (TypeMirror type : superTypes) {
        TypeElement superElement = env.getProcessingEnvironment().getElementUtils()
                .getTypeElement(type.toString());
        if (superElement == null)
            continue;
        if (superElement.getKind().equals(ElementKind.INTERFACE))
            continue;
        if (superElement.asType().toString().equals(Object.class.getCanonicalName()))
            continue;
        createInformationForMethods(superElement, actionInfo, methodsHandled);
    }

}