I am running into a weird case where the compile is complaining about raw use of parameterized class. I understand the problem but I am not sure how to fix it.
public enum Notify {
CHAT, EMAIL
}
public interface NotifyMessageCreator<T> {
Collection<Messages> createMessages(T t);
Notify getNotify();
}
public ChatMessageCreator implements NotifyMessageCreator<T> {
Collection<Messages> createMessages(DocumentTypeA document){
...
}
public Notify getNotify(){
return Notify.CHAT;
}
}
public ChatMessageCreator implements NotifyMessageCreator<T> {
Collection<Messages> createMessages(TimeInterval interval){
...
}
public Notify getNotify(){
return Notify.EMAIL;
}
}
public class NotifyFactory {
//this is where it complains about the raw use because I don't know how to
//make the field generic
private final Map<Notify, NotifyMessageCreator> notifyMessageCreatorFactory;
//spring will give me all of the classes with this interface
public NotifyFactory(List<NotifyMessageCreator> notifyMessageCreators){
notifyMessageCreatorFactory = new HashMap();
notifyMessageCreators.forEach(c -> notifyMessageCreatorFactory.put(c.getNotify(), c);
}
//this also gives a raw warning
public NotifyMessageCreator getMesssageCreator(Notify notify){
return notifyMessageCreatorFactory.get(notify);
}
}
Not sure how to get around the raw parameter warning.