Example usage for java.lang.annotation AnnotationTypeMismatchException element

List of usage examples for java.lang.annotation AnnotationTypeMismatchException element

Introduction

In this page you can find the example usage for java.lang.annotation AnnotationTypeMismatchException element.

Prototype

Method element

To view the source code for java.lang.annotation AnnotationTypeMismatchException element.

Click Source Link

Document

The Method object for the annotation element.

Usage

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

/**
 * This method is responsible for calling {@link #processMethod(RestApi, ExecutableElement)} and catch all exceptions.
 *
 * @param api           rest api//from   w w  w .  j  a  v  a  2 s. c  o  m
 * @param methodElement method element
 */
private void processMethodWithCatchException(@NotNull RestApi api, @NotNull ExecutableElement methodElement) {
    try {
        processMethod(api, methodElement);
    } catch (AnnotationTypeMismatchException e) {
        String className = methodElement.getEnclosingElement().getSimpleName().toString();
        String message = String.format(
                "Unable to read annotation parameter '%s' for %s.%s(). Try to use simple inline String.",
                e.element().getName(), className, methodElement.getSimpleName());
        AnnotationMirror annotationMirror = getAnnotationMirror(methodElement,
                e.element().getDeclaringClass().getName());
        AnnotationValue annotationValue = getAnnotationValue(annotationMirror, e.element().getName() + "()");
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement, annotationMirror,
                annotationValue);
    } catch (Exception e) {
        String message = String.format("%s: %s", e.getClass().getName(), e.getStackTrace()[0]);
        ThreadLocalContext.getMessager().printMessage(WARNING, message, methodElement);
    }
}