I have the below code to instantiate all the service on the start of the application. Sonar lint on the IndicesFactory is complaining for generic raw type. What is the best way to fix this?
public class IndicesFactory {
private final Map<String, IndicesStrategy> indicesMap;
public IndicesFactory(List<IndicesStrategy> indicesStrategyList) {
this.indicesMap = new HashMap<>();
indicesStrategyList.forEach(strategy -> this.indicesMap.put(strategy.getOperation().toString(), strategy));
}
private IndicesStrategy getStrategy(String operation) {
return this.indicesMap.get(operation);
}
public <T, R> R execute(String operation, T t) {
return (R) getStrategy(operation).execute(t);
}}
And my IndicesStrategy interface has below code
public interface IndicesStrategy<operation extends Enum<?>, T, R extends
IndicesResponse> {
R execute(T t);
operation getOperation();
}