我通过反射创建我的枚举,因为我为每个枚举添加了一个实现抽象工厂的内部类.现在我想访问这个内部类以调用该方法:
@Factory(FooFactory.class)
public enum Foo {
FOO,BAR;
public class FooFactory implements AbstractFactory {
public Foo create(String value) {
return valueOf(value.toUpperCase());
}
}
}
@Factory的定义是:
@Retention(RetentionPolicy.RUNTIME)
public @interface Factory {
Class> value();
}
但是,有了这个,我收到以下错误:
Class cannot be resolved to a type FooFactory.java
当我尝试@Factory(Foo $FooFactory.class)时,我收到错误:
The nested Foo$FooFactory cannot be referneced using its binary name.
那么甚至可以引用嵌套类吗?