I'm new to cglib, but it seems like the right tool for the job, so here goes:
Suppose I have an annotation classes Foo
and Bar
, and an enum class B
, such that Foo
and Bar
are declared as follows:
public @interface Foo {
public B value();
}
public @interface Bar {
public B value();
}
Now, suppose I have this:
public class AnnotationImpl<A extends Annotation, B extends Enum<B>> {
public AnnotationImpl(Class<A> annotationClass, B value);
// value() returns value, annotationType() returns annotationClass
// Implement equals(), hashCode(), toString() as specified
}
It seems repetitive to have to subclass AnnotationImpl
for both Foo
and Bar
when they are more or less identical; is it possible to use cglib to have a method makeImpl()
taking an an annotation class that returns an AnnotationImpl
that implements that annotation class? eg. makeImpl(Foo.class, B.ONE)
returns a Foo
backed by AnnotationImpl(Foo.class, B.ONE)
?