View Javadoc
1   package com.zone.weixin4j.dispatcher;
2   
3   import com.zone.weixin4j.type.AccountType;
4   import com.zone.weixin4j.util.ServerToolkits;
5   
6   import java.io.Serializable;
7   
8   /**
9    * 微信消息key
10   * 
11   * @className WeixinMessageKey
12   * @author jinyu(foxinmy@gmail.com)
13   * @date 2015年6月9日
14   * @since JDK 1.6
15   * @see
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  }