### Question:
MethodsViaSerialization implements Methods<T> { public Method<T> get(Consumer<T> consumer) { return method(consumer); } MethodsViaSerialization(Class<T> type); Method<T> get(Consumer<T> consumer); Method<T> get(BiConsumer<T, P1> consumer); @Override Method<T> get(TriConsumer<T, P1, P2> triConsumer); @Override Method<T> get(QuadConsumer<T, P1, P2, P3> quadConsumer); Method<T> get(Function<T, R> function); Method<T> get(BiFunction<T, P1, R> function); Method<T> get(TriFunction<T, P1, P2, R> function); Method<T> get(QuadFunction<T, P1, P2, P3, R> function);  }### Answer:
@Test public void testInterface() { final Methods<I> methods = new MethodsViaSerialization<>(I.class); final Method<I> m1 = methods.get(I::m1); assertEquals("m1", m1.getMethod().getName()); assertEquals(I.class, m1.getDeclaringClass()); final Method<I> m2 = methods.get(I::m2); assertEquals("m2", m2.getMethod().getName()); assertEquals(I.class, m2.getDeclaringClass()); final Method<I> m3 = methods.get(I::m3); assertEquals("m3", m3.getMethod().getName()); assertEquals(I.class, m3.getDeclaringClass()); final Method<I> m4 = methods.get(I::m4); assertEquals("m4", m4.getMethod().getName()); assertEquals(I.class, m4.getDeclaringClass()); final Method<I> m5 = methods.get(I::m5); assertEquals("m5", m5.getMethod().getName()); assertEquals(I.class, m5.getDeclaringClass()); final Method<I> m6 = methods.get(I::m6); assertEquals("m6", m6.getMethod().getName()); assertEquals(I.class, m6.getDeclaringClass()); }
@Test public void test() { final MethodsViaSerialization<C> methods = new MethodsViaSerialization<>(C.class); assertEquals("x", methods.get(C::x).getMethod().getName()); final MethodsViaSerialization<Object> obj = new MethodsViaSerialization<>(Object.class); assertEquals("y", obj.get(C::y).getMethod().getName()); }