@Test void getDeclaredMethodForMethodThatExistsIsTheMethod() { Method method0 = ClassUtil.getDeclaredMethod(TestingTarget.class, "method"); assertThat(method0, notNullValue()); assertThat(method0.getName(), is("method")); }
public static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes) { return declaredMethod(aClass, name, parameterTypes) .orElseThrow(() -> new NoSuchElementException(String.format("No such method as %s(%s) in %s", name, Arrays.stream(parameterTypes).map(Object::toString).collect(joining(", ")), aClass))); }
ClassUtil extends UtilityClass { public static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes) { return declaredMethod(aClass, name, parameterTypes) .orElseThrow(() -> new NoSuchElementException(String.format("No such method as %s(%s) in %s", name, Arrays.stream(parameterTypes).map(Object::toString).collect(joining(", ")), aClass))); } }
ClassUtil extends UtilityClass { public static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes) { return declaredMethod(aClass, name, parameterTypes) .orElseThrow(() -> new NoSuchElementException(String.format("No such method as %s(%s) in %s", name, Arrays.stream(parameterTypes).map(Object::toString).collect(joining(", ")), aClass))); }  }
ClassUtil extends UtilityClass { public static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes) { return declaredMethod(aClass, name, parameterTypes) .orElseThrow(() -> new NoSuchElementException(String.format("No such method as %s(%s) in %s", name, Arrays.stream(parameterTypes).map(Object::toString).collect(joining(", ")), aClass))); }  @SuppressWarnings("unchecked") static Class<T> forObject(T value); static Optional<Class<?>> forName(String className); static Optional<Class<?>> forArrayOf(Class<?> componentClass); static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes); static Optional<Method> declaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes); static Stream<Method> declaredMethods(Class<?> aClass); static Field getDeclaredField(Class<?> aClass, String fieldName); static Optional<Field> declaredField(Class<?> aClass, String fieldName); static Optional<Field> findField(Class<?> aClass, String fieldName); static Optional<Class<?>> superclass(Class<?> aClass); static Stream<Class<?>> superclasses(Class<?> aClass); static boolean hasAnnotation(Class<?> aClass, Class<A> annotationClass); static Optional<A> annotation(Class<T> aClass, Class<A> annotationClass); static Stream<A> annotations(Class<T> aClass, Class<A> annotationClass); static Optional<Constructor<T>> constructor(Class<T> aClass, Class<?>... parameterTypes); }
ClassUtil extends UtilityClass { public static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes) { return declaredMethod(aClass, name, parameterTypes) .orElseThrow(() -> new NoSuchElementException(String.format("No such method as %s(%s) in %s", name, Arrays.stream(parameterTypes).map(Object::toString).collect(joining(", ")), aClass))); }  @SuppressWarnings("unchecked") static Class<T> forObject(T value); static Optional<Class<?>> forName(String className); static Optional<Class<?>> forArrayOf(Class<?> componentClass); static Method getDeclaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes); static Optional<Method> declaredMethod(Class<?> aClass, String name, Class<?>... parameterTypes); static Stream<Method> declaredMethods(Class<?> aClass); static Field getDeclaredField(Class<?> aClass, String fieldName); static Optional<Field> declaredField(Class<?> aClass, String fieldName); static Optional<Field> findField(Class<?> aClass, String fieldName); static Optional<Class<?>> superclass(Class<?> aClass); static Stream<Class<?>> superclasses(Class<?> aClass); static boolean hasAnnotation(Class<?> aClass, Class<A> annotationClass); static Optional<A> annotation(Class<T> aClass, Class<A> annotationClass); static Stream<A> annotations(Class<T> aClass, Class<A> annotationClass); static Optional<Constructor<T>> constructor(Class<T> aClass, Class<?>... parameterTypes);  }