All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.lang.born.DynaMethodBorning Maven / Gradle / Ivy

Go to download

Nutz, which is a collections of lightweight frameworks, each of them can be used independently

There is a newer version: 1.r.72
Show newest version
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);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy