1 package com.foxinmy.weixin4j.dispatcher;
2
3 import java.io.Serializable;
4
5 import com.foxinmy.weixin4j.type.AccountType;
6 import com.foxinmy.weixin4j.util.ServerToolkits;
7
8
9
10
11
12
13
14
15
16
17 public class WeixinMessageKey implements Serializable {
18
19 private static final long serialVersionUID = -691330687850400289L;
20
21 private String messageType;
22 private String eventType;
23 private AccountType accountType;
24
25 public WeixinMessageKey(String messageType, String eventType,
26 AccountType accountType) {
27 this.messageType = messageType;
28 this.eventType = eventType;
29 this.accountType = accountType;
30 }
31
32 public String getMessageType() {
33 return messageType;
34 }
35
36 public String getEventType() {
37 return eventType;
38 }
39
40 public AccountType getAccountType() {
41 return accountType;
42 }
43
44 @Override
45 public int hashCode() {
46 final int prime = 31;
47 int result = 1;
48 result = prime * result
49 + ((accountType == null) ? 0 : accountType.hashCode());
50 result = prime * result
51 + ((ServerToolkits.isBlank(eventType)) ? 0 : eventType.hashCode());
52 result = prime
53 * result
54 + ((ServerToolkits.isBlank(messageType)) ? 0 : messageType
55 .hashCode());
56 return result;
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj)
62 return true;
63 if (obj == null)
64 return false;
65 if (getClass() != obj.getClass())
66 return false;
67 WeixinMessageKey other = (WeixinMessageKey) obj;
68 if (accountType != other.accountType)
69 return false;
70 if (eventType == null) {
71 if (other.eventType != null)
72 return false;
73 } else if (!eventType.equalsIgnoreCase(other.eventType))
74 return false;
75 if (messageType == null) {
76 if (other.messageType != null)
77 return false;
78 } else if (!messageType.equalsIgnoreCase(other.messageType))
79 return false;
80 return true;
81 }
82
83 @Override
84 public String toString() {
85 return "WeixinMessageKey [messageType=" + messageType + ", eventType="
86 + eventType + ", accountType=" + accountType + "]";
87 }
88 }