package com.example.demo.classloader.reflection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class XMethod {
    private final Method method;

    XMethod(Method method) {
        this.method = method;
    }

    public XValue invoke(Object target, Object... args) throws InvocationTargetException {
        try {
            return new XValue(method.invoke(target, args));
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }

    public Method method() {
        return method;
    }
}
