package de.skuzzle.inject.async.internal;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import de.skuzzle.inject.async.annotation.Trigger;

final class Annotations {

    private Annotations() {
        // hidden ctor
    }

    /**
     * Searches the annotations of the provided method for an annotation type
     * that itself is annotated with {@link Trigger}. An exception is thrown if
     * the method does not have a unique Trigger annotation.
     *
     * @param method The method to search.
     * @return The unique trigger annotation.
     */
    static Annotation findTriggerAnnotation(Method method) {
        Annotation result = null;
        for (final Annotation annotation : method.getAnnotations()) {
            if (isTriggerAnnotation(annotation)) {
                if (result == null) {
                    result = annotation;
                } else {
                    throw new IllegalStateException(String.format(
                            "Multiple @Trigger annotations found on '%s': %s, %s",
                            method, result, annotation));
                }
            }
        }
        if (result == null) {
            throw new IllegalStateException(String.format(
                    "No @Trigger annotation found on '%s'", method));
        }
        return result;
    }

    private static boolean isTriggerAnnotation(Annotation annotation) {
        final Class<?> type = annotation.annotationType();
        if (type.isAnnotationPresent(Trigger.class)) {
            return true;
        }
        return false;
    }
}

@@ -332,23 +332,16 @@
 ion type
-%0A     *
  that it
@@ -344,16 +344,23 @@
 t itself
+%0A     *
  is anno
@@ -412,23 +412,16 @@
 hrown if
-%0A     *
  the met
@@ -432,16 +432,23 @@
 does not
+%0A     *
  have a 
@@ -1486,20 +1486,23 @@
         
-if (
+return 
 type.isA
@@ -1536,67 +1536,8 @@
 ass)
-) %7B%0A            return true;%0A        %7D%0A        return false
 ;%0A  

Simplify expression