I have some code like so:
private void processMessage(MessageType message, MessageHandler<MessageType> handler)
{
handler.handleMessage(message);
}
With message handler being an abstract class.
public abstract class MessageHandler <T extends MessageType>
{
public abstract T handleMessage(T message);
}
I have a child class:
public class FooBarHandler extends MessageHandler<FooBarMessageType>
{
public FooBarMessageType handleMessage(FooBarMessageType message)
{...}
}
Where FooBarMessageType is a subclass of MessageType.
Now, when I call processMessage as such:
processMessage((FooBarMessageType)message, new FooBarHandler());
I get this error in eclipse:
The method processMessage(MessageType, MessageHandler) in the type StuffDoer is not applicable for the arguments (FooBarMessageType, FooBarHandler)
I noticed that when I made the second formal parameter for processMessage raw:
private void processMessage(MessageType message, MessageHandler handler)
It just becomes a warning. However, the only solution eclipse gives to fix this warning generates the error again.