package com.hammurapi.common.concurrent;

import java.util.Arrays;

import com.hammurapi.common.Context;

public class InvocationImpl<K> implements Invocation<K>, Cloneable {

	private Object[] arguments;
	private PropertySet<K> propertySet;
	private Context context;
	
	public InvocationImpl() {
		
	}

	public InvocationImpl(Invocation<K> source) {
		arguments = source.getArguments()==null ? null : Arrays.copyOf(source.getArguments(), source.getArguments().length);
		propertySet = source.getPropertySet();
		context = source.getContext();
	}
	
	public InvocationImpl(Object[] arguments, PropertySet<K> propertySet, Context context) {
		super();
		this.arguments = arguments;
		this.propertySet = propertySet;
		this.context = context;
	}

	@Override
	public Object[] getArguments() {
		return arguments;
	}

	@Override
	public PropertySet<K> getPropertySet() {
		return propertySet;
	}

	@Override
	public Context getContext() {
		return context;
	}
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		InvocationImpl<K> ret = (InvocationImpl<K>) super.clone();
		if (arguments!=null) {
			ret.setArguments(Arrays.copyOf(arguments, arguments.length));
		}
		return ret;
	}

	public void setArguments(Object[] arguments) {
		this.arguments = arguments;
	}

	public void setPropertySet(PropertySet<K> propertySet) {
		this.propertySet = propertySet;
	}

	public void setContext(Context context) {
		this.context = context;
	}
	
	

}
