plugins.adufour.vars.gui.model
Class ValueSelectionModel<T>

java.lang.Object
  extended by plugins.adufour.vars.gui.model.ValueSelectionModel<T>
Type Parameters:
T -
All Implemented Interfaces:
VarEditorModel<T>
Direct Known Subclasses:
TypeSelectionModel

public class ValueSelectionModel<T>
extends java.lang.Object
implements VarEditorModel<T>

Variable constraint that only allows to choose from a specified set of values

Author:
Alexandre Dufour

Field Summary
protected  T defaultValue
           
protected  java.util.List<T> validValues
           
 
Constructor Summary
ValueSelectionModel()
           
ValueSelectionModel(T[] validValues)
           
ValueSelectionModel(T[] validValues, int defaultValueIndex, boolean freeInput)
           
ValueSelectionModel(T[] validValues, T defaultValue, boolean freeInput)
           
 
Method Summary
 T getDefaultValue()
           
 java.util.List<T> getValidValues()
           
 boolean isFreeInput()
           
 boolean isValid(T value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validValues

protected final java.util.List<T> validValues

defaultValue

protected final T defaultValue
Constructor Detail

ValueSelectionModel

public ValueSelectionModel()

ValueSelectionModel

public ValueSelectionModel(T[] validValues)

ValueSelectionModel

public ValueSelectionModel(T[] validValues,
                           int defaultValueIndex,
                           boolean freeInput)
Parameters:
validValues - a list of valid values
defaultValueIndex - the index of the default selected value
freeInput - set to true if any valid outside the list is valid (no check will be performed)

ValueSelectionModel

public ValueSelectionModel(T[] validValues,
                           T defaultValue,
                           boolean freeInput)
Parameters:
validValues - a list of valid values
defaultValue - the default selected value
freeInput - set to true if any valid outside the list is valid (no check will be performed)
Method Detail

isValid

public boolean isValid(T value)
Specified by:
isValid in interface VarEditorModel<T>

getDefaultValue

public T getDefaultValue()
Specified by:
getDefaultValue in interface VarEditorModel<T>

getValidValues

public java.util.List<T> getValidValues()

isFreeInput

public boolean isFreeInput()