1 16 17 package org.springframework.beans.factory.support; 18 19 import java.lang.reflect.Method ; 20 21 import org.springframework.util.Assert; 22 import org.springframework.util.ObjectUtils; 23 24 33 public class LookupOverride extends MethodOverride { 34 35 private final String beanName; 36 37 38 45 public LookupOverride(String methodName, String beanName) { 46 super(methodName); 47 Assert.notNull(beanName, "Bean name must not be null"); 48 this.beanName = beanName; 49 } 50 51 54 public String getBeanName() { 55 return this.beanName; 56 } 57 58 59 62 public boolean matches(Method method) { 63 return (method.getName().equals(getMethodName()) && method.getParameterTypes().length == 0); 64 } 65 66 67 public String toString() { 68 return "LookupOverride for method '" + getMethodName() + "'; will return bean '" + this.beanName + "'"; 69 } 70 71 public boolean equals(Object other) { 72 return (other instanceof LookupOverride && super.equals(other) && 73 ObjectUtils.nullSafeEquals(this.beanName, ((LookupOverride) other).beanName)); 74 } 75 76 public int hashCode() { 77 return (29 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.beanName)); 78 } 79 80 } 81 | Popular Tags |