### Question:
Reflections { public static Value<Method> method(Class<?> clazz, String method, Object... args) { Conditions.nonNull(clazz, "clazz"); Conditions.nonNullOrEmpty(method, "method"); try { if (args != null && args.length > 0) { Class<?>[] types = Stream.of(args).map(Object::getClass).toArray(Class<?>[]::new); return Value.of(clazz.getDeclaredMethod(method, types)); } return Value.of(clazz.getDeclaredMethod(method)); } catch (ReflectiveOperationException error) { return Value.empty(); } } private  Reflections(); static Object proxy(InvocationHandler handler, Collection<Class<?>> classes); static Object proxy(InvocationHandler handler, Class<?>... classes); static T proxy(Class<T> proxy, InvocationHandler handler, Collection<Class<?>> classes); static T proxy(Class<T> proxy, InvocationHandler handler, Class<?>... classes); static Value<Method> method(Class<?> clazz, String method, Object... args); static Value<Method> methodElevated(Class<?> clazz, String method, Object... args); static Value<Object> invoke(Object instance, String method, Object... args); static Value<Object> invoke(Class<?> clazz, String method, Object... args); static Value<Object> invoke(Class<?> clazz, Object instance, String method, Object... args); static Value<Object> invoke(Method invoke, Object... args); static Value<Object> invoke(Object instance, Method invoke, Object... args); static Value<Field> field(Class<?> clazz, String name); static Value<Field> fieldElevated(Class<?> clazz, String name); static boolean setter(Object instance, String name, Object set); static boolean setter(Class<?> clazz, String name, Object set); static boolean setter(Class<?> clazz, Object instance, String name, Object set); static boolean setter(Field field, Object set); static boolean setter(Object instance, Field field, Object set); @SuppressWarnings("unchecked") static Value<T> getter(Object instance, String name); static Value<T> getter(Class<?> clazz, String name); @SuppressWarnings("unchecked") static Value<T> getter(Class<?> clazz, Object instance, String name); static Value<T> getter(Field field); @SuppressWarnings("unchecked") static Value<T> getter(Object instance, Field field); static Value<T> instance(String signature, Class<T> clazz, Object... args); static Value<T> instance(Class<T> clazz, Object... args); static Value<Class<?>> clazz(String name); static Value<Class<?>> clazz(String name, boolean init, ClassLoader loader);  }### Answer:
@Test public void methodTest() { MyObject object = new MyObject(); Value<Object> value = Reflections.invoke(object, "foo"); Assert.assertTrue(value.isPresent()); Assert.assertEquals(object.foo(), value.get()); Assert.assertEquals("foo", Reflections.invoke(MyObject.class, "bar").get()); }