package eu.dnetlib.contract.runner;

import org.contract4j5.contract.Contract;
import org.contract4j5.contract.Post;
import org.contract4j5.contract.Pre;

/**
 * Invoker infomations including target object, method name and parameters.
 * @author mhorst
 *
 */
@Contract
public class InvokerData {

	/**
	 * Target object.
	 */
	private Object target;
	
	/**
	 * Method name to be invoked on target object.
	 */
	private String methodName;
	
	/**
	 * Parameter types of given method.
	 * This is optional element, the parameter types can be extracted from args if no types are specified.
	 */
	private Class<?>[] parameterTypes;
	
	/**
	 * Arguments array required by the method invoked on target object.
	 */
	private Object[] args;

	
	/**
	 * Returns target object.
	 * @return target object
	 */
	@Post("$return != null")
	public Object getTarget() {
		return target;
	}

	/**
	 * Sets target object.
	 * @param target
	 */
	@Pre("target != null")
	public void setTarget(Object target) {
		this.target = target;
	}

	/**
	 * Returns method name to be invoked on target object.
	 * @return method name to be invoked on target object
	 */
	@Post("$return != null")
	public String getMethodName() {
		return methodName;
	}

	/**
	 * Sets method name to be invoked on target object.
	 * @param methodName
	 */
	@Pre("methodName != null")
	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	/**
	 * Returns parameter types of given method.
	 * @return parameter types of given method
	 */
	public Class<?>[] getParameterTypes() {
		return parameterTypes;
	}

	/**
	 * Sets parameter types of given method.
	 * @param parameterTypes
	 */
	public void setParameterTypes(Class<?>[] parameterTypes) {
		this.parameterTypes = parameterTypes;
	}
	
	/**
	 * Returns arguments array required by the method invoked on target object.
	 * @return arguments array required by the method invoked on target object
	 */
	public Object[] getArgs() {
		return args;
	}

	/**
	 * Sets arguments array required by the method invoked on target object.
	 * @param args
	 */
	public void setArgs(Object[] args) {
		this.args = args;
	}
	
}
