Search in sources :

Example 1 with ModifiedMethod

use of org.fakereplace.data.ModifiedMethod in project fakereplace by fakereplace.

the class AnnotationReflection method getAnnotations.

public static Annotation[] getAnnotations(Method clazz) {
    if (AnnotationDataStore.isMethodDataRecorded(clazz)) {
        Annotation[] result = AnnotationDataStore.getMethodAnnotations(clazz);
        int rc = 0;
        boolean found = false;
        for (Annotation a : result) {
            if (a instanceof ModifiedMethod) {
                found = true;
                break;
            }
        }
        if (!found) {
            return result;
        }
        Annotation[] ret = new Annotation[result.length - 1];
        for (Annotation a : result) {
            if (!(a instanceof ModifiedMethod)) {
                ret[rc] = a;
                rc++;
            }
        }
        return ret;
    }
    if (clazz.isAnnotationPresent(ModifiedMethod.class)) {
        Annotation[] d = clazz.getAnnotations();
        Annotation[] ret = new Annotation[d.length - 1];
        int rc = 0;
        for (Annotation a : d) {
            if (!(a instanceof ModifiedMethod)) {
                ret[rc] = a;
                rc++;
            }
        }
        return ret;
    }
    return clazz.getAnnotations();
}
Also used : ModifiedMethod(org.fakereplace.data.ModifiedMethod) Annotation(java.lang.annotation.Annotation)

Example 2 with ModifiedMethod

use of org.fakereplace.data.ModifiedMethod in project fakereplace by fakereplace.

the class AnnotationReflection method getDeclaredAnnotations.

public static Annotation[] getDeclaredAnnotations(Method clazz) {
    if (AnnotationDataStore.isMethodDataRecorded(clazz)) {
        Annotation[] result = AnnotationDataStore.getMethodAnnotations(clazz);
        int rc = 0;
        boolean found = false;
        for (Annotation a : result) {
            if (a instanceof ModifiedMethod) {
                found = true;
                break;
            }
        }
        if (!found) {
            return result;
        }
        Annotation[] ret = new Annotation[result.length - 1];
        for (Annotation a : result) {
            if (!(a instanceof ModifiedMethod)) {
                ret[rc] = a;
                rc++;
            }
        }
        return ret;
    }
    if (clazz.isAnnotationPresent(ModifiedMethod.class)) {
        Annotation[] d = clazz.getDeclaredAnnotations();
        Annotation[] ret = new Annotation[d.length - 1];
        int rc = 0;
        for (Annotation a : d) {
            if (!(a instanceof ModifiedMethod)) {
                ret[rc] = a;
                rc++;
            }
        }
        return ret;
    }
    return clazz.getDeclaredAnnotations();
}
Also used : ModifiedMethod(org.fakereplace.data.ModifiedMethod) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)2 ModifiedMethod (org.fakereplace.data.ModifiedMethod)2