List of utility methods to do Reflection Method Annotation
List | getMethodAnnotations(Method m) For a give Method m determine Annotation s in the following manner:
|
List | getMethodByAnnotation(Class> cls, Class extends Annotation> annotationClass) get Method By Annotation List<Method> result = new ArrayList<Method>(); Method[] methods = cls.getDeclaredMethods(); for (Method method : methods) { if (method.isAnnotationPresent(annotationClass)) { result.add(method); Class<?> superClass = cls.getSuperclass(); ... |
List | getMethodContainsAnnotations(Class target, Class annotation) get Method Contains Annotations List<Method> fieldsDaClasse = getMethods(target);
return (List<Method>) fieldsDaClasse.stream()
.filter((Method method) -> method.isAnnotationPresent(annotation)).collect(Collectors.toList());
|
ArrayList | getMethodInClassWithAnnotation(Class> cls, Class extends Annotation> annotationClass, int... modifiers) Gibt die Methode aus der gegebenen Klasse mit dem gegebenen Namen, den gegebenen Argumenten zurueck und den gegebenenen Modifiern zurueck. ArrayList<Method> methods = new ArrayList<Method>(); for (Method m : cls.getDeclaredMethods()) { if (m.isAnnotationPresent(annotationClass) && hasAllModifiers(m, modifiers)) { methods.add(m); return methods; |
Set | getMethodLevelAnnotations(Class> clazz, Class get Method Level Annotations Set<T> result = new HashSet<T>(); Set<Method> annotatedMethods = getMethodsAnnotatedWith(clazz, annotation); for (Method annotatedMethod : annotatedMethods) { result.add(annotatedMethod.getAnnotation(annotation)); return result; |
String | getMethodName(final Class extends Annotation> annoType, final Class> klazType) get Method Name final Method[] methodArray = klazType.getDeclaredMethods(); for (final Method method : methodArray) { final Annotation anno = method.getAnnotation(annoType); if (anno != null) { return method.getName(); return null; ... |
T | getMethodOrClassLevelAnnotation(Class get Method Or Class Level Annotation T annotation = method.getAnnotation(annotationClass); if (annotation != null) { return annotation; return getClassLevelAnnotation(annotationClass, clazz); |
Method[] | getMethods(Annotation anno) get Methods ArrayList<Method> methods = new ArrayList<Method>(); Class<? extends Annotation> cls = anno.annotationType(); for (Method method : cls.getDeclaredMethods()) { if (Modifier.isPublic(method.getModifiers()) && method.getDeclaringClass() == cls) { methods.add(method); return methods.toArray(new Method[methods.size()]); ... |
Method[] | getMethods(Class> clazz, Class extends Annotation> annotation) get Methods List<Method> methods = new ArrayList(); for (Method m : clazz.getMethods()) { if (m.isAnnotationPresent(annotation)) { methods.add(m); return methods.toArray(new Method[0]); |
List | getMethods(final Class> clazz, final Class extends Annotation> annotation) Return all method(s) of a specified class that contain the specified annotation. final List<Method> annotatedMethods = new LinkedList<Method>(); for (Method method : clazz.getMethods()) { if (method.isAnnotationPresent(annotation)) { annotatedMethods.add(method); return annotatedMethods; |