1 4 package com.tcspring; 5 6 7 public class ComplexBeanId { 8 private String scopeId = null; 9 private String beanName = null; 10 11 public ComplexBeanId(String beanName) { 12 this("singleton", beanName); 13 } 14 15 public ComplexBeanId(String newScopeId, String newBeanName) { 16 this.scopeId = newScopeId; 17 this.beanName = newBeanName; 18 } 19 20 public String getBeanName() { 21 return beanName; 22 } 23 24 public String getScopeId() { 25 return scopeId; 26 } 27 28 public int hashCode() { 29 return (31 * scopeId.hashCode()) + beanName.hashCode(); 30 } 31 32 public boolean equals(Object obj) { 33 if (this == obj) return true; 34 if (obj == null) return false; 35 if (getClass() != obj.getClass()) return false; 36 37 ComplexBeanId other = (ComplexBeanId) obj; 38 if (beanName == null) { 39 if (other.beanName != null) { 40 return false; 41 } 42 } else if (!beanName.equals(other.beanName)) { 43 return false; 44 } 45 46 if (scopeId == null) { 47 if (other.scopeId != null) { 48 return false; 49 } 50 } else if (!scopeId.equals(other.scopeId)) { 51 return false; 52 } 53 54 return true; 55 } 56 57 public String toString() { 58 return scopeId + ":" + beanName; 59 } 60 61 } 62 63 | Popular Tags |