1 18 package org.apache.activemq.pool; 19 20 25 public class ConnectionKey { 26 private String userName; 27 private String password; 28 private int hash; 29 30 public ConnectionKey(String password, String userName) { 31 this.password = password; 32 this.userName = userName; 33 hash = 31; 34 if (userName != null) { 35 hash += userName.hashCode(); 36 } 37 hash *= 31; 38 if (password != null) { 39 hash += password.hashCode(); 40 } 41 } 42 43 public int hashCode() { 44 return hash; 45 } 46 47 public boolean equals(Object that) { 48 if (this == that) { 49 return true; 50 } 51 if (that instanceof ConnectionKey) { 52 return equals((ConnectionKey) that); 53 } 54 return false; 55 } 56 57 public boolean equals(ConnectionKey that) { 58 return isEqual(this.userName, that.userName) && isEqual(this.password, that.password); 59 } 60 61 public String getPassword() { 62 return password; 63 } 64 65 public String getUserName() { 66 return userName; 67 } 68 69 public static boolean isEqual(Object o1, Object o2) { 70 if (o1 == o2) { 71 return true; 72 } 73 return (o1 != null && o2 != null && o1.equals(o2)); 74 } 75 76 77 } 78 | Popular Tags |