rulebook-core/src/main/java/com/deliveredtechnologies/rulebook/util/AnnotationUtils.java
@SuppressWarnings("unchecked")
  public static List<Method> getAnnotatedMethods(Class annotation, Class clazz) {
    List<Method> methods = new ArrayList<>();
    if (clazz == Object.class) {
      return methods;
    }
    methods.addAll((List<Method>)
        Arrays.stream(clazz.getDeclaredMethods())
        .filter(field -> field.getAnnotation(annotation) != null)
        .collect(Collectors.toList()));
    methods.addAll(getAnnotatedMethods(annotation, clazz.getSuperclass()));
    return methods;
  }
@SuppressWarnings("unchecked")
  public static List<Method> getAnnotatedMethods(Class annotation, Class clazz) {
    List<Method> methods = new ArrayList<>();
    if (clazz == Object.class) {
      return methods;
    }
    methods.addAll((List<Method>)
        Arrays.stream(clazz.getDeclaredMethods())
        .filter(field -> field.getAnnotation(annotation) != null)
        .collect(Collectors.toList()));
    methods.addAll(getAnnotatedMethods(annotation, clazz.getSuperclass()));
    return methods;
  }
@ SuppressWarnings ( "unchecked" ) public static List < Method > getAnnotatedMethods ( Class annotation , Class clazz ) { List < Method > methods = new ArrayList <> ( ) ; if ( clazz == Object . class ) { return methods ; } methods . addAll ( ( List < Method > ) Arrays . stream ( clazz . getDeclaredMethods ( ) ) . filter ( field -> field . getAnnotation ( annotation ) != null ) . collect ( Collectors . toList ( ) ) ) ; methods . addAll ( getAnnotatedMethods ( annotation , clazz . getSuperclass ( ) ) ) ; return methods ; }
Method getAnnotatedMethods gets the methods annotated of a specific type from the class and its parent
classes.<br/> The List is in order of closest parent => current obj methods, parent obj methods, etc.
@param annotation      the type of the annotation
@param clazz           the annotated class
@return                a List of Methods that have been annotated using annotation in the class clazz
Method getAnnotatedMethods gets the methods annotated of a specific type from the class and its parent classes . <br / > The List is in order of closest parent = > current obj methods parent obj methods etc .