I create my enums through reflection, for that I add to each enum an inner class which implements the abstract factory. Now I want to access this inner class in order to invoke the method:
@Factory(FooFactory.class)
public enum Foo {
FOO, BAR;
public class FooFactory implements AbstractFactory<Foo> {
public Foo create(String value) {
return valueOf(value.toUpperCase());
}
}
}
The definition of @Factory is:
@Retention(RetentionPolicy.RUNTIME)
public @interface Factory {
Class<?> value();
}
With this, however, I receive the following error:
Class cannot be resolved to a type FooFactory.java
When I try @Factory(Foo$FooFactory.class) I receive the error:
The nested Foo$FooFactory cannot be referneced using its binary name.
So is it even possible to reference a nested class?
From the comments… apparently
was needed.