1 8 9 15 package jfun.yan; 16 17 import java.util.Arrays ; 18 19 import jfun.util.Misc; 20 21 29 final class DynamicMethodBinder implements ComponentBinder { 30 31 private final String mname; 32 private final Class [] param_types; 33 private final boolean suppress_security; 34 private boolean isParameterless(){ 35 return param_types==null || param_types.length==0; 36 } 37 DynamicMethodBinder(final String mname, final Class [] param_types, 38 boolean suppress_security) { 39 this.mname = mname; 40 this.param_types = param_types; 41 this.suppress_security = suppress_security; 42 } 43 44 public Verifiable verify(Class type) { 45 return Components.fun( 46 Functions.method(type, null, mname, param_types, suppress_security) 47 ); 48 } 49 public Creator bind(Object v){ 50 return Components.fun(Functions.method( 51 v, mname, param_types, suppress_security 52 ) 53 ); 54 } 55 public Class bindType(Class t){ 56 return null; 57 } 58 public boolean equals(Object obj) { 59 if(obj instanceof DynamicMethodBinder){ 60 final DynamicMethodBinder other = (DynamicMethodBinder)obj; 61 if(!mname.equals(other.mname)) return false; 62 if(suppress_security!=other.suppress_security) return false; 63 if(isParameterless()) return other.isParameterless(); 64 return Arrays.equals(param_types, other.param_types); 65 } 66 else return false; 67 } 68 public int hashCode() { 69 int hcode = mname.hashCode(); 70 if(param_types==null) return hcode*31; 71 return 31*Misc.getArrayHashcode(param_types)+hcode; 72 } 73 public String toString() { 74 return mname+jfun.yan.util.Utils.toString(param_types); 75 } 76 } 77 | Popular Tags |