org.nutz.lang.born.DynaMethodBorning Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nutz Show documentation
Show all versions of nutz Show documentation
Nutz, which is a collections of lightweight frameworks, each of them can be used independently
package org.nutz.lang.born;
import java.lang.reflect.Method;
import org.nutz.lang.Mirror;
public class DynaMethodBorning implements Borning {
private Method method;
public DynaMethodBorning(Method method) {
this.method = method;
if (!method.isAccessible())
this.method.setAccessible(true);
}
@SuppressWarnings("unchecked")
public T born(Object... args) {
try {
return (T) method.invoke(null, Mirror.evalArgToRealArray(args));
}
catch (Exception e) {
throw new BorningException(e, method.getDeclaringClass(), args);
}
}
}