1 8 9 15 package jfun.yan.lifecycle; 16 17 import java.io.Serializable ; 18 import java.util.Arrays ; 19 20 import jfun.util.StringUtils; 21 22 23 final class MethodNameProcedure implements Procedure, Serializable { 24 private final String name; 25 private final Class [] param_types; 26 MethodNameProcedure(String name, Class [] ptypes) { 27 this.name = name; 28 this.param_types = ptypes; 29 } 30 31 public String toString(){ 32 return name+StringUtils.listString("(", ", ", ")", param_types); 33 } 34 35 public boolean equals(Object obj) { 36 if(obj instanceof MethodNameProcedure){ 37 final MethodNameProcedure other = (MethodNameProcedure)obj; 38 return name.equals(other.name) && Arrays.equals(param_types, other.param_types); 39 40 } 41 return false; 42 } 43 44 public int hashCode() { 45 return name.hashCode(); 46 } 47 48 public void invoke(Object self, Object [] args) throws Throwable { 49 MethodProcedure.invokeMethod(self, 50 self.getClass().getMethod(name, param_types), args); 51 } 52 } 53 | Popular Tags |