/*
 * This code is copyright (c) 2005 David Owen.  All rights not explicitly
 * granted by the author are reserved.
 *
 * Created on Aug 2, 2005.
 */
package ws.fugue88.access;

import java.lang.reflect.InvocationTargetException;

/**
 * Provides parameterized bindings to specific references to objects (not
 * necessarily to specific objects).
 * 
 * @author dsowen
 */
public interface Accessor {

	/**
	 * Returns the natural type of the reference bound by this accessor. This
	 * should:
	 * <ul>
	 * <li>return the same type for every binding to the reference;</li>
	 * <li>return that type independent of the actual type of the referenced
	 * object; and,</li>
	 * <li>return that type even if the reference is currently
	 * <code>null</code> or non-existent.</li>
	 * </ul>
	 * 
	 * @return
	 */
	Class getType();

	/**
	 * Clears the reference bound by this accessor. For references that may be
	 * deleted without losing the ability to set it, it should be deleted (e.g.
	 * the key in a map may be removed).
	 * 
	 * @throws InvocationTargetException
	 */
	void clearValue() throws InvocationTargetException;

	/**
	 * Returns the current object to which the reference refers. If the
	 * reference does not exist, <code>null</code> should be returned.
	 * 
	 * @return the current value, or <code>null</code> if no reference
	 * @throws InvocationTargetException
	 */
	Object getValue() throws InvocationTargetException;

	/**
	 * Sets the reference to refer to the given object. If the reference does
	 * not exist, it is created.
	 * 
	 * @param value
	 * @throws InvocationTargetException
	 */
	void setValue(Object value) throws InvocationTargetException;
}