package org.codemucker.jfind.matcher;

import java.lang.annotation.Annotation;

import org.codemucker.jmatch.AString;
import org.codemucker.jmatch.AbstractNotNullMatcher;
import org.codemucker.jmatch.Description;
import org.codemucker.jmatch.MatchDiagnostics;
import org.codemucker.jmatch.Matcher;
import org.codemucker.jmatch.ObjectMatcher;

public class AnAnnotation extends ObjectMatcher<Annotation> {

    public static AnAnnotation with() {
        return new AnAnnotation();
    }

    public AnAnnotation() {
        super(Annotation.class);
    }

    public <A extends Annotation> AnAnnotation fullName(final Class<A> annotationClass) {
        fullName(annotationClass.getName());
        return this;
    }

    public AnAnnotation fullName(final String name) {
        fullName(AString.equalTo(name));
        return this;
    }

    public AnAnnotation fullName(final Matcher<String> matcher) {
        addMatcher(new AbstractNotNullMatcher<Annotation>() {
            @Override
            public boolean matchesSafely(Annotation found, MatchDiagnostics diag) {
                return diag.tryMatch(this, found.annotationType().getName(), matcher);
            }

            @Override
            public void describeTo(Description desc) {
                desc.value("fullName", matcher);
            }
        });
        return this;
    }
}

@@ -1395,11 +1395,616 @@
 %0A    %7D%0D%0A
+    %0D%0A    public AnAnnotation annotationPresent(final Class%3C? extends Annotation%3E annotationPresent) %7B%0D%0A        addMatcher(new AbstractNotNullMatcher%3CAnnotation%3E() %7B%0D%0A            @Override%0D%0A            public boolean matchesSafely(Annotation found, MatchDiagnostics diag) %7B%0D%0A                return found.annotationType().isAnnotationPresent(annotationPresent);%0D%0A            %7D%0D%0A%0D%0A            @Override%0D%0A            public void describeTo(Description desc) %7B%0D%0A                desc.value(%22annotationPresetn%22, annotationPresent.getClass().getName());%0D%0A            %7D%0D%0A        %7D);%0D%0A        return this;%0D%0A    %7D%0D%0A
 %7D%0D%0A

add matcher for annotation present on annotations