package de.ugoe.cs.quest.eventcore.gui;

/**
 * TODO comment
 * 
 * @version $Revision: $ $Date: $
 * @author 2011, last modified by $Author: $
 */
public class ValueSelection<T> implements IInteraction {
    
    /**  */
    private static final long serialVersionUID = 1L;

    /** */
    private T selectedValue;

    /**
     * TODO: comment
     * 
     * @param selectedValue
     */
    public ValueSelection(T selectedValue) {
        this.selectedValue = selectedValue;
    }

    /*
     * (non-Javadoc)
     * 
     * @see de.harms.attef.userinteraction.Interaction#getName()
     */
    public String getName() {
        return "ValueSelection";
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "select value";
    }

    /*
     * (non-Javadoc)
     * 
     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
     */
    public boolean startsLogicalSequence() {
        return false;
    }

    /*
     * (non-Javadoc)
     * 
     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
     */
    public boolean finishesLogicalSequence() {
        return false;
    }

    /**
     * @return the selectedValue
     */
    public T getSelectedValue() {
        return selectedValue;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if ((obj == null) || (!(obj instanceof ValueSelection<?>))) {
            return false;
        }

        ValueSelection<?> otherValueSelection = (ValueSelection<?>) obj;

        return
            ((otherValueSelection != null) &&
             ((selectedValue == otherValueSelection.selectedValue) ||
              ((selectedValue != null) &&
               (selectedValue.equals(otherValueSelection.selectedValue)))));
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        return selectedValue.hashCode();
    }

}
