public class MagicMatcher <T> implements InvocationHandler { //... public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if () { //... } else { if (args.length > 1) { throw new IllegalArgumentException("Cannot assert more than one argument at once."); } methodMap.put(method.getName(), args[0]); return proxy; } } //... }