The following snippet might be useful for other than myself:
public abstract class ATypedApplication<t> implements ReceivingApplication
{
protected abstract Message processMessage(T message);</t>
@Override
public boolean canProcess(Message in)
{
return true;
}
@SuppressWarnings("unchecked")
@Override
public Message processMessage(Message paramMessage, Map<String, Object> paramMap) throws ReceivingApplicationException, HL7Exception
{
return processMessage((T) paramMessage);
}
}
What do you use "T" for?
Do you have separate ReceivingApplication classes by concrete message type?
Yep - like the following:
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.model.v25.message.ADT_A01;
public class SomeMessageHandler extends ATypedApplication<adt_a01>{</adt_a01>
}
+1 for this feature, I use it too
Now ReceivingApplication is parameterized regarding the type of the message (<t extends="" message="">) and processMessage accepts type T. All references to this class have been parameterized as well. Additionally, there's an abstract ClassBasedReceivingApplication class that only accept message of a given class. This can be extended for more specific purposes.</t>