View Javadoc

1   /*
2    * Created on 21-Apr-2004
3    */
4   package ca.uhn.hl7v2.protocol.impl;
5   
6   import ca.uhn.hl7v2.protocol.ApplicationRouter;
7   import ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData;
8   
9   /**
10   * A default implementation of <code>ApplicationRouter.AppRoutingData</code>. 
11   * 
12   * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
13   * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
14   */
15  public class AppRoutingDataImpl implements ApplicationRouter.AppRoutingData {
16  
17      private final String myMessageType;
18      private final String myTriggerEvent;
19      private final String myProcessingId;
20      private final String myVersionId;
21       
22      /**
23       * Creates a new instance with args used as values that will be returned 
24       * by the corresponding getters.
25       */
26      public AppRoutingDataImpl(String theMessageType, String theTriggerEvent, 
27                  String theProcessingId, String theVersionId) {
28          myMessageType = theMessageType;
29          myTriggerEvent = theTriggerEvent;
30          myProcessingId = theProcessingId;
31          myVersionId = theVersionId;
32      }
33  
34      /**
35       * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getMessageType()
36       */
37      public String getMessageType() {
38          return myMessageType;
39      }
40  
41      /**
42       * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getTriggerEvent()
43       */
44      public String getTriggerEvent() {
45          return myTriggerEvent;
46      }
47  
48      /** 
49       * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getProcessingId()
50       */
51      public String getProcessingId() {
52          return myProcessingId;
53      }
54  
55      /** 
56       * @see ca.uhn.hl7v2.protocol.ApplicationRouter.AppRoutingData#getVersion()
57       */
58      public String getVersion() {
59          return myVersionId;
60      }
61  
62      @Override
63      public boolean equals(Object o) {
64          if (this == o) return true;
65          if (!(o instanceof AppRoutingDataImpl)) return false;
66  
67          AppRoutingDataImpl that = (AppRoutingDataImpl) o;
68  
69          if (myMessageType != null ? !myMessageType.equals(that.myMessageType) : that.myMessageType != null)
70              return false;
71          if (myProcessingId != null ? !myProcessingId.equals(that.myProcessingId) : that.myProcessingId != null)
72              return false;
73          if (myTriggerEvent != null ? !myTriggerEvent.equals(that.myTriggerEvent) : that.myTriggerEvent != null)
74              return false;
75          if (myVersionId != null ? !myVersionId.equals(that.myVersionId) : that.myVersionId != null)
76              return false;
77  
78          return true;
79      }
80  
81      @Override
82      public int hashCode() {
83          int result = myMessageType != null ? myMessageType.hashCode() : 0;
84          result = 31 * result + (myTriggerEvent != null ? myTriggerEvent.hashCode() : 0);
85          result = 31 * result + (myProcessingId != null ? myProcessingId.hashCode() : 0);
86          result = 31 * result + (myVersionId != null ? myVersionId.hashCode() : 0);
87          return result;
88      }
89  
90      /**
91       * Returns an instance of AppRoutingData which accepts all
92       * message types, versions, etc.
93       */
94  	public static AppRoutingData withAll() {
95  		return new AppRoutingDataImpl("*","*", "*", "*");
96  	}
97  
98  }