1 16 17 package org.springframework.beans.factory.support; 18 19 import java.lang.reflect.Method ; 20 import java.util.HashSet ; 21 import java.util.Iterator ; 22 import java.util.Set ; 23 24 37 public class MethodOverrides { 38 39 private final Set overrides = new HashSet (); 40 41 42 45 public MethodOverrides() { 46 } 47 48 51 public MethodOverrides(MethodOverrides other) { 52 addOverrides(other); 53 } 54 55 56 59 public void addOverrides(MethodOverrides other) { 60 if (other != null) { 61 this.overrides.addAll(other.getOverrides()); 62 } 63 } 64 65 68 public void addOverride(MethodOverride override) { 69 this.overrides.add(override); 70 } 71 72 77 public Set getOverrides() { 78 return overrides; 79 } 80 81 84 public boolean isEmpty() { 85 return this.overrides.isEmpty(); 86 } 87 88 93 public MethodOverride getOverride(Method method) { 94 for (Iterator it = this.overrides.iterator(); it.hasNext();) { 95 MethodOverride methodOverride = (MethodOverride) it.next(); 96 if (methodOverride.matches(method)) { 97 return methodOverride; 98 } 99 } 100 return null; 101 } 102 103 public boolean equals(Object o) { 104 if (this == o) return true; 105 if (o == null || getClass() != o.getClass()) return false; 106 107 MethodOverrides that = (MethodOverrides) o; 108 109 if (!this.overrides.equals(that.overrides)) return false; 110 111 return true; 112 } 113 114 public int hashCode() { 115 return this.overrides.hashCode(); 116 } 117 } 118 | Popular Tags |