/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.springframework.util.ReflectionUtils
 */
package com.hst.task.support;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;
import org.springframework.util.ReflectionUtils;

public class ScheduledMethodRunnable
implements Runnable {
    private final Object target;
    private final Method method;
    private final Object[] args;

    public ScheduledMethodRunnable(Object target, Method method) {
        this.target = target;
        this.method = method;
        this.args = null;
    }

    public ScheduledMethodRunnable(Object target, String methodName) throws NoSuchMethodException {
        this.target = target;
        this.method = target.getClass().getMethod(methodName, new Class[0]);
        this.args = null;
    }

    public ScheduledMethodRunnable(Object target, String methodName, Object ... args) throws NoSuchMethodException {
        Class[] parClass;
        this.target = target;
        if (args == null) {
            parClass = new Class[]{};
        } else {
            parClass = new Class[args.length];
            int i = 0;
            while (i < args.length) {
                parClass[i] = args[i].getClass();
                ++i;
            }
        }
        this.method = target.getClass().getMethod(methodName, parClass);
        this.args = args;
    }

    public Object getTarget() {
        return this.target;
    }

    public Method getMethod() {
        return this.method;
    }

    @Override
    public void run() {
        try {
            ReflectionUtils.makeAccessible((Method)this.method);
            Object[] par = this.args == null ? new Object[]{} : this.args;
            this.method.invoke(this.target, par);
        }
        catch (InvocationTargetException var2) {
            ReflectionUtils.rethrowRuntimeException((Throwable)var2.getTargetException());
        }
        catch (IllegalAccessException var3) {
            throw new UndeclaredThrowableException(var3);
        }
    }
}
