1 8 9 15 package jfun.yan.lifecycle; 16 17 import java.io.Serializable ; 18 import java.lang.reflect.Method ; 19 import jfun.util.SerializableMethod; 20 21 final class MethodProcedure implements Procedure, Serializable { 22 private final SerializableMethod mtd; 23 public void invoke(Object self, Object [] args) throws Throwable { 24 invokeMethod(self, mtd.getMethod(), args); 25 } 26 MethodProcedure(Method mtd) { 27 this.mtd = new SerializableMethod(mtd); 28 } 29 static void invokeMethod(Object self, Method mtd, Object [] args) 30 throws Throwable { 31 mtd.invoke(self, args); 32 } 33 public boolean equals(Object obj) { 34 if(obj instanceof MethodProcedure){ 35 final MethodProcedure other = (MethodProcedure)obj; 36 return mtd.equals(other.mtd); 37 } 38 else return false; 39 } 40 public int hashCode() { 41 return mtd.hashCode(); 42 } 43 public String toString() { 44 return mtd.toString(); 45 } 46 } 47 | Popular Tags |