1 package jfun.yan; 2 3 import java.lang.reflect.Method ; 4 5 import jfun.yan.util.ReflectionUtil; 6 7 final class MethodNameParamCountBinder implements ComponentBinder { 8 public Verifiable verify(Class type) { 9 final Method mtd = ReflectionUtil.getMethod(type, mname, 10 param_count, suppress_security); 11 return Components.fun(Functions.method(null, mtd)); 12 } 13 public Creator bind(Object v){ 14 if(v==null) 15 throw new IllegalArgumentException ("cannot invoke method " 16 + mname + " against null."); 17 final Class type = v.getClass(); 18 final Method mtd = ReflectionUtil.getMethod(type, mname, 19 param_count, suppress_security); 20 return Components.fun(Functions.method(v, mtd)); 21 } 22 public Class bindType(Class t){ 23 return null; 24 } 25 private final String mname; 26 private final int param_count; 27 private final boolean suppress_security; 28 MethodNameParamCountBinder(final String mname, 29 final int param_count, boolean suppress_security) { 30 this.mname = mname; 31 this.param_count = param_count; 32 this.suppress_security = suppress_security; 33 } 34 35 public boolean equals(Object obj) { 36 if(obj instanceof MethodNameParamCountBinder){ 37 final MethodNameParamCountBinder other = (MethodNameParamCountBinder)obj; 38 return suppress_security==other.suppress_security && 39 param_count == other.param_count && 40 mname.equals(other.mname); 41 } 42 else return false; 43 } 44 public int hashCode() { 45 return mname.hashCode()*31+param_count; 46 } 47 public String toString() { 48 return mname.toString(); 49 } 50 } 51 | Popular Tags |