1 22 23 24 package com.mchange.v2.c3p0.impl; 25 26 import java.io.*; 27 import com.mchange.v2.lang.ObjectUtils; 28 import com.mchange.v2.ser.UnsupportedVersionException; 29 30 public final class DbAuth implements Serializable 31 { 32 transient String username; 33 transient String password; 34 35 public DbAuth(String username, String password) 36 { 37 this.username = username; 38 this.password = password; 39 } 40 41 public String getUser() 42 { return username; } 43 44 public String getPassword() 45 { return password; } 46 47 public boolean equals(Object o) 48 { 49 if (this == o) 50 return true; 51 else if (o != null && this.getClass() == o.getClass()) 52 { 53 DbAuth other = (DbAuth) o; 54 return 55 ObjectUtils.eqOrBothNull(this.username, other.username) && 56 ObjectUtils.eqOrBothNull(this.password, other.password); 57 } 58 else 59 return false; 60 } 61 62 public int hashCode() 63 { 64 return 65 ObjectUtils.hashOrZero(username) ^ 66 ObjectUtils.hashOrZero(password); 67 } 68 69 static final long serialVersionUID = 1; private final static short VERSION = 0x0001; 72 73 private void writeObject(ObjectOutputStream out) throws IOException 74 { 75 out.writeShort(VERSION); 76 out.writeObject(username); out.writeObject(password); } 79 80 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException 81 { 82 short version = in.readShort(); 83 switch (version) 84 { 85 case 0x0001: 86 this.username = (String ) in.readObject(); 87 this.password = (String ) in.readObject(); 88 break; 89 default: 90 throw new UnsupportedVersionException(this, version); 91 } 92 } 93 } 94 95 96 97 98 99 | Popular Tags |