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

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

Introduction

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

Prototype

@Override
TypeMirror asType();

Source Link

Document

Returns the ExecutableType executable type defined by this executable element.

Usage

From source file:cop.raml.processor.RestProcessor.java

/**
 * Read response data from given {@code methodElement} and put it into {@code res}. In general case it's impossible to correctly detect type of
 * return value automatically//from ww  w  .  j  a va2s.  c  o  m
 *
 * @param res           rest method result
 * @param methodElement current method
 * @param methodJavaDoc javadoc
 */
private void readResponse(@NotNull RestMethod res, @NotNull ExecutableElement methodElement,
        @NotNull MethodJavaDoc methodJavaDoc) {
    String[] mediaTypes = checkMediaTypes(restImpl.getResponseMediaTypes(methodElement));
    TagReturn ret = methodJavaDoc.getReturn();
    TypeElement element = ThreadLocalContext.getImportedElement(ret.getLink().getClassName());

    if (element == null)
        element = ThreadLocalContext.getImportedElement(methodElement.asType().toString());

    Response response = res.addResponse(ret != TagReturn.NULL ? ret.getStatus() : HttpStatus.OK.value());
    response.setDescription(ret.getText());

    for (String mediaType : mediaTypes) {
        Body body = response.addBody(mediaType);
        body.setExample(exampleProvider.getExample(element, mediaType, ret.isArray()));
    }
}