1 16 17 package org.apache.commons.dbcp.datasources; 18 19 import java.io.Serializable ; 20 21 25 class UserPassKey implements Serializable { 26 private String password; 27 private String username; 28 29 UserPassKey(String username, String password) { 30 this.username = username; 31 this.password = password; 32 } 33 34 38 public String getPassword() { 39 return password; 40 } 41 42 46 public String getUsername() { 47 return username; 48 } 49 50 55 public boolean equals(Object obj) { 56 if (obj == null) { 57 return false; 58 } 59 60 if (obj == this) { 61 return true; 62 } 63 64 if (!(obj instanceof UserPassKey)) { 65 return false; 66 } 67 68 UserPassKey key = (UserPassKey) obj; 69 70 boolean usersEqual = 71 (this.username == null 72 ? key.username == null 73 : this.username.equals(key.username)); 74 75 boolean passwordsEqual = 76 (this.password == null 77 ? key.password == null 78 : this.password.equals(key.password)); 79 80 return (usersEqual && passwordsEqual); 81 } 82 83 public int hashCode() { 84 return (this.username != null ? this.username.hashCode() : 0); 85 } 86 87 public String toString() { 88 StringBuffer sb = new StringBuffer (50); 89 sb.append("UserPassKey("); 90 sb.append(username).append(", ").append(password).append(')'); 91 return sb.toString(); 92 } 93 } 94 | Popular Tags |