generator.setSuperclass(Object.class);
generator.setInterfaces(new Class<?>[] { intfs });
generator.setCallbacks(new Callback[] {
// default callback
new MethodInterceptor() {
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable {
return proxy.invokeSuper(obj, args);
}
},
// toString callback
new MethodInterceptor() {
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable {
MapBuilder mb = new MapBuilder().setPrintCount(true).setSortKeys(true);
for (Map.Entry<Method, FastMethod> entry : methodMappings.entrySet()) {
mb.append(
entry.getKey().getName(),
getSimpleMethodSignature(entry.getValue().getJavaMethod(), false, true, true, false));
}
return new ToStringBuilder().append(intfs.getName()).append(mb).toString();
}
},
// proxied callback
new MethodInterceptor() {
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy)
throws Throwable {
FastMethod realMethod = assertNotNull(methodMappings.get(method), "unknown method: %s", method);
return realMethod.invoke(null, args);
}