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

com.mercateo.reflection.Call Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.mercateo.reflection;

import java.lang.reflect.Method;
import java.util.function.Consumer;

import com.mercateo.reflection.proxy.ProxyFactory;

public class Call {

    private final Class clazz;

    private final Method method;

    private final Object[] args;

    public Call(Class clazz, Method method, Object[] args) {
        this.clazz = clazz;
        this.method = method;
        this.args = args;
    }

    public static  Call of(Class clazz, Consumer invocation) {
        final T proxy = ProxyFactory.createProxy(clazz);
        invocation.accept(proxy);

        // noinspection unchecked
        return ((InvocationRecorder) proxy).getInvocationRecordingResult();
    }

    public static  Method methodOf(Class clazz, Consumer invocation) {
        return of(clazz, invocation).method();
    }

    public Class declaringClass() {
        return clazz;
    }

    public Method method() {
        return method;
    }

    public Object[] args() {
        return args;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy