001/*
002 * Created on 21-Apr-2004
003 */
004package ca.uhn.hl7v2.protocol.impl;
005
006import ca.uhn.hl7v2.protocol.ApplicationRouter;
007import ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData;
008
009/**
010 * A default implementation of <code>ApplicationRouter.AppRoutingData</code>. 
011 * 
012 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
013 * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
014 */
015public class AppRoutingDataImpl implements ApplicationRouter.AppRoutingData {
016
017    private final String myMessageType;
018    private final String myTriggerEvent;
019    private final String myProcessingId;
020    private final String myVersionId;
021     
022    /**
023     * Creates a new instance with args used as values that will be returned 
024     * by the corresponding getters.
025     */
026    public AppRoutingDataImpl(String theMessageType, String theTriggerEvent, 
027                String theProcessingId, String theVersionId) {
028        myMessageType = theMessageType;
029        myTriggerEvent = theTriggerEvent;
030        myProcessingId = theProcessingId;
031        myVersionId = theVersionId;
032    }
033
034    /**
035     * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getMessageType()
036     */
037    public String getMessageType() {
038        return myMessageType;
039    }
040
041    /**
042     * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getTriggerEvent()
043     */
044    public String getTriggerEvent() {
045        return myTriggerEvent;
046    }
047
048    /** 
049     * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getProcessingId()
050     */
051    public String getProcessingId() {
052        return myProcessingId;
053    }
054
055    /** 
056     * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getVersion()
057     */
058    public String getVersion() {
059        return myVersionId;
060    }
061
062    @Override
063    public boolean equals(Object o) {
064        if (this == o) return true;
065        if (!(o instanceof AppRoutingDataImpl)) return false;
066
067        AppRoutingDataImpl that = (AppRoutingDataImpl) o;
068
069        if (myMessageType != null ? !myMessageType.equals(that.myMessageType) : that.myMessageType != null)
070            return false;
071        if (myProcessingId != null ? !myProcessingId.equals(that.myProcessingId) : that.myProcessingId != null)
072            return false;
073        if (myTriggerEvent != null ? !myTriggerEvent.equals(that.myTriggerEvent) : that.myTriggerEvent != null)
074            return false;
075        if (myVersionId != null ? !myVersionId.equals(that.myVersionId) : that.myVersionId != null)
076            return false;
077
078        return true;
079    }
080
081    @Override
082    public int hashCode() {
083        int result = myMessageType != null ? myMessageType.hashCode() : 0;
084        result = 31 * result + (myTriggerEvent != null ? myTriggerEvent.hashCode() : 0);
085        result = 31 * result + (myProcessingId != null ? myProcessingId.hashCode() : 0);
086        result = 31 * result + (myVersionId != null ? myVersionId.hashCode() : 0);
087        return result;
088    }
089
090    /**
091     * Returns an instance of AppRoutingData which accepts all
092     * message types, versions, etc.
093     */
094        public static AppRoutingData withAll() {
095                return new AppRoutingDataImpl("*","*", "*", "*");
096        }
097
098}