@Test public void delegatesMethodCall() { Delegator<InterfaceType> firstArgumentDelegator = (instance, method, arguments) -> arguments[0]; InterfaceType interfaceProxy = new Proxy<>(InterfaceType.class).instance(firstArgumentDelegator); assertEquals("value", interfaceProxy.aMethod("value")); }
public T instance(Delegator<T> delegator) { try { T instance = makeProxyFor(type, delegator).newInstance(); return instance; } catch (InstantiationException | IllegalAccessException | IllegalAccessError e) { throw new ProxyInstanceCreationFailed(type, e); } }
Proxy { public T instance(Delegator<T> delegator) { try { T instance = makeProxyFor(type, delegator).newInstance(); return instance; } catch (InstantiationException | IllegalAccessException | IllegalAccessError e) { throw new ProxyInstanceCreationFailed(type, e); } } }
Proxy { public T instance(Delegator<T> delegator) { try { T instance = makeProxyFor(type, delegator).newInstance(); return instance; } catch (InstantiationException | IllegalAccessException | IllegalAccessError e) { throw new ProxyInstanceCreationFailed(type, e); } } Proxy(Class<T> type); }
Proxy { public T instance(Delegator<T> delegator) { try { T instance = makeProxyFor(type, delegator).newInstance(); return instance; } catch (InstantiationException | IllegalAccessException | IllegalAccessError e) { throw new ProxyInstanceCreationFailed(type, e); } } Proxy(Class<T> type); T instance(Delegator<T> delegator); }
Proxy { public T instance(Delegator<T> delegator) { try { T instance = makeProxyFor(type, delegator).newInstance(); return instance; } catch (InstantiationException | IllegalAccessException | IllegalAccessError e) { throw new ProxyInstanceCreationFailed(type, e); } } Proxy(Class<T> type); T instance(Delegator<T> delegator);  }