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