
package uk.co.wingpath.util;

import java.util.*;
import java.text.*;
import java.math.*;
import uk.co.wingpath.event.*;

/**
* This interface is implemented by classes that are used to store values
* and monitor changes to them.
* <p>A value of type <code>T</code> may stored in the variable using the
* {@link #setValue} method, and the value may be retrieved using the
* {@link #getValue} method.
* <p>A {@link ValueListener} may be added to a variable to monitor
* changes to the value of the variable.
* The {@link ValueListener#valueChanged valueChanged} method
* of the listener may be called when the {@link #setValue} method is used
* to change the value. The listener will NOT be called if the old and new
* values are the same, as determined by the <code>equals</code> method of
* type <code>T</code>.
*/
public interface Variable<T>
{
    /**
    * Gets the value of the variable.
    * @return the value of the variable.
    */
    T getValue ();

    /**
    * Sets the value of the variable.
    * <p>If the new value is not equal to the old value, the
    * <code>valueChanged</code> method of each listener may be called.
    * @param value the new value.
    */
    void setValue (T value);

    /**
    * Adds the specified listener.
    * @param l the listener to be added.
    */
    void addValueListener (ValueListener l);

    /**
    * Removes the specified listener.
    * @param l the listener to be removed.
    */
    void removeValueListener (ValueListener l);
}

