public static List<Method> getMethods(final Object object) {
   final List<Method> methods =
       ReflectionUtils.getAllMethods(object.getClass())
           .stream() //
           .filter(
               method -> !IGNORE_BY_CLASSNAME.contains(method.getDeclaringClass().getName())) //
           .filter(method -> !method.getName().contains("$jacoco")) //
           .sorted((method1, method2) -> method1.getName().compareTo(method2.getName())) //
           .collect(Collectors.toList());
   final Set<String> uniqueNames = Sets.newHashSet();
   // TODO handle overloaded methods with same name correct (now they will filtered)
   return methods
       .stream()
       .filter(
           method -> {
             if (uniqueNames.contains(method.getName())) {
               return false;
             }
             uniqueNames.add(method.getName());
             return true;
           })
       .filter(
           method ->
               !method.getDeclaringClass().equals(ConsoleScript.class)
                   || !method.getName().equals("run"))
       .collect(Collectors.toList());
 }
Example #2
0
 static java.util.Set<Method> relevantMethods(Class<?> c, Class<? extends Annotation> a) {
   return ReflectionUtils.getAllMethods(c, Predicates.and(ReflectionUtils.withAnnotation(a)));
 }