1 18 package org.apache.activemq.util; 19 20 import org.apache.activemq.command.SubscriptionInfo; 21 22 public class SubscriptionKey { 23 24 public final String clientId; 25 public final String subscriptionName; 26 private final int hashValue; 27 28 29 public SubscriptionKey(SubscriptionInfo info) { 30 this(info.getClientId(), info.getSubcriptionName()); 31 } 32 33 public SubscriptionKey(String clientId, String subscriptionName) { 34 this.clientId = clientId; 35 this.subscriptionName = subscriptionName != null? subscriptionName : "NOT_SET"; 36 hashValue = clientId.hashCode()^this.subscriptionName.hashCode(); 37 } 38 39 40 public int hashCode() { 41 return hashValue; 42 } 43 44 public boolean equals(Object o) { 45 try { 46 SubscriptionKey key = (SubscriptionKey) o; 47 return key.clientId.equals(clientId) && key.subscriptionName.equals(subscriptionName); 48 } catch (Throwable e) { 49 return false; 50 } 51 } 52 53 public String toString() { 54 return clientId+":"+subscriptionName; 55 } 56 57 public String getClientId() { 58 return clientId; 59 } 60 61 public String getSubscriptionName() { 62 return subscriptionName; 63 } 64 } 65 | Popular Tags |