1 16 17 package org.springframework.beans.factory.support; 18 19 import java.lang.reflect.Method ; 20 21 import org.springframework.beans.BeanMetadataElement; 22 import org.springframework.util.Assert; 23 import org.springframework.util.ObjectUtils; 24 25 36 public abstract class MethodOverride implements BeanMetadataElement { 37 38 private final String methodName; 39 40 private boolean overloaded = true; 41 42 private Object source; 43 44 45 49 protected MethodOverride(String methodName) { 50 Assert.notNull(methodName, "Method name must not be null"); 51 this.methodName = methodName; 52 } 53 54 57 public String getMethodName() { 58 return this.methodName; 59 } 60 61 66 protected void setOverloaded(boolean overloaded) { 67 this.overloaded = overloaded; 68 } 69 70 74 protected boolean isOverloaded() { 75 return this.overloaded; 76 } 77 78 82 public void setSource(Object source) { 83 this.source = source; 84 } 85 86 public Object getSource() { 87 return this.source; 88 } 89 90 91 98 public abstract boolean matches(Method method); 99 100 101 public boolean equals(Object other) { 102 if (this == other) { 103 return true; 104 } 105 if (!(other instanceof MethodOverride)) { 106 return false; 107 } 108 MethodOverride that = (MethodOverride) other; 109 return (ObjectUtils.nullSafeEquals(this.methodName, that.methodName) && 110 this.overloaded == that.overloaded && 111 ObjectUtils.nullSafeEquals(this.source, that.source)); 112 } 113 114 public int hashCode() { 115 int hashCode = ObjectUtils.nullSafeHashCode(this.methodName); 116 hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.source); 117 hashCode = 29 * hashCode + (this.overloaded ? 1 : 0); 118 return hashCode; 119 } 120 121 } 122 | Popular Tags |