Package org.codehaus.backport175.compiler

Examples of org.codehaus.backport175.compiler.AnnotationC


     * @param annotation the annotation class
     * @param method     the java.lang.refect.Method object to find the annotation on.
     * @return the annotation or null
     */
    public static Annotation getAnnotation(final Class annotation, final Method method) {
        final AnnotationReader reader = AnnotationReader.getReaderFor(method.getDeclaringClass());
        return reader.getAnnotation(getAnnnotationName(annotation), method);
    }
View Full Code Here


     * @param annotationType the annotation type
     * @param constructor the annotated type
     * @return true if the annotation is present else false
     */
    public static boolean isAnnotationPresent(final Class annotationType, final Constructor constructor) {
        final AnnotationReader reader = AnnotationReader.getReaderFor(constructor.getDeclaringClass());
        return reader.isAnnotationPresent(annotationType, constructor);
    }
View Full Code Here

     * @param annotation  the annotation class
     * @param constructor the java.lang.refect.Constructor object to find the annotation on.
     * @return the annotation or null
     */
    public static Annotation getAnnotation(final Class annotation, final Constructor constructor) {
        final AnnotationReader reader = AnnotationReader.getReaderFor(constructor.getDeclaringClass());
        return reader.getAnnotation(getAnnnotationName(annotation), constructor);
    }
View Full Code Here

     * @param annotation the annotation class
     * @param field      the java.lang.reflect.Field object to find the annotation on.
     * @return the annotation or null
     */
    public static Annotation getAnnotation(final Class annotation, final Field field) {
        final AnnotationReader reader = AnnotationReader.getReaderFor(field.getDeclaringClass());
        return reader.getAnnotation(getAnnnotationName(annotation), field);
    }
View Full Code Here

    public AnnotationReaderTest(String name) {
        super(name);
    }

    public void testToString() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Complex", Target.METHOD);
        assertEquals(
                "@test.TestAnnotations$Complex(" +
                "i=111, " +
                "doubleArr=[1.1, 2.2, 3.3, 4.4], " +
                "type=double[][][].class, " +
View Full Code Here

        ));
        assertFalse(Annotations.isAnnotationPresent(Target.class, Target.class));
    }

    public void testClassAnn1() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$VoidTyped");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.VoidTyped.class, type);
    }
View Full Code Here

        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.VoidTyped.class, type);
    }

    public void testClassAnn2() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$DefaultString");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.DefaultString.class, type);

        TestAnnotations.DefaultString ann = (TestAnnotations.DefaultString)annotation;
        assertEquals("hello", ann.value());
View Full Code Here

        TestAnnotations.DefaultString ann = (TestAnnotations.DefaultString)annotation;
        assertEquals("hello", ann.value());
    }

    public void testClassAnn3() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Simple");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.Simple.class, type);

        TestAnnotations.Simple ann = (TestAnnotations.Simple)annotation;
        assertEquals("foo", ann.val());
View Full Code Here

        assertEquals("foo", ann.val());
        assertEquals("bar", ann.s());
    }

    public void testClassAnn4() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$StringArray");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.StringArray.class, type);

        TestAnnotations.StringArray ann = (TestAnnotations.StringArray)annotation;
        String[] ss = ann.ss();
View Full Code Here

        assertEquals("hello", ss[0]);
        assertEquals("world", ss[1]);
    }

    public void testClassAnn5() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$LongArray");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.LongArray.class, type);

        TestAnnotations.LongArray ann = (TestAnnotations.LongArray)annotation;
        long[] longArr = ann.l();
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.compiler.AnnotationC

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.