I am trying to provide an opportunity to inject an arbitrary enum given injection point and string value (that is obtained in Produces method)
Arbitrary means if I have enum My and enum Your I would like to inject both of them or any other one with the same producer method.
So I tried several approaches: 1.
@Produces
@MyConfigAnnotation
Enum getArbitraryEnum(InjectionPoint point) {
...
// get string representation,
// instantiate enum using point
return Enum.valueOf((Class<Enum>)injectionPoint.getAnnotated().getClass(), enumValue);
}
2. I changed return type to Object.
In both cases I receive the next exception Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type TestEnum with qualifiers @X at injection point [BackedAnnotatedField] @Inject @X pathToMyField.testEnum2
So is there any way to create a Produces method that will be able to produce an arbitrary enum.