public abstract class ParameterType<T>
extends java.lang.Object
ParameterType
is used by objects that take some kind of parameter input from an user.Modifier and Type | Field and Description |
---|---|
private boolean |
checkValues |
private java.lang.Class<T> |
clazz
The class of allowed parameter values.
|
private T |
defaultValue
Default value of the parameter.
|
private Enumeration<T,java.lang.String> |
enumeration
List of allowed values.
|
private int |
height
Height of the input field for the parameter in the GUI.
|
private java.util.List<T> |
items
List of allowed values.
|
private int |
multiplicity
How many values that can be tied to this
parameter. 0 is unlimited values and 1 is default.
|
private boolean |
notNull
If the parameter can be null or not.
|
private Type |
valueType
The matching type of parameter values (can be null)
|
private int |
width
Width of the input field for the parameter in the GUI.
|
Constructor and Description |
---|
ParameterType(Type valueType,
java.lang.Class<T> clazz)
Creates a parameter type with no default value and allowing null values.
|
ParameterType(Type valueType,
java.lang.Class<T> clazz,
T defaultValue,
boolean notNull)
Creates a new parameter type.
|
ParameterType(Type valueType,
java.lang.Class<T> clazz,
T defaultValue,
boolean notNull,
int multiplicity,
int width,
int height) |
ParameterType(Type valueType,
java.lang.Class<T> clazz,
T defaultValue,
boolean notNull,
int multiplicity,
int width,
int height,
Enumeration<T,java.lang.String> enumeration,
boolean checkValues) |
ParameterType(Type valueType,
java.lang.Class<T> clazz,
T defaultValue,
boolean notNull,
int multiplicity,
int width,
int height,
java.util.List<T> items) |
Modifier and Type | Method and Description |
---|---|
T |
getDefaultValue()
Get the default value.
|
Enumeration<T,java.lang.String> |
getEnumeration()
Get the list of values to choose from as an enumeration.
|
int |
getHeight()
Get the height of the input field for the parameter in the GUI.
|
java.util.List<T> |
getItems()
Get the list of values to choose from.
|
int |
getMultiplicity()
Get how many values that can be tied to this
parameter. 0 is unlimited values and 1 is default.
|
boolean |
getNotNull()
Check if the parameter can be null.
|
java.lang.Class<T> |
getParameterClass()
Get the class a value must have to match this parameter type.
|
Type |
getValueType()
Get the date type of values that can be stored in this parameter.
|
int |
getWidth()
Get the width of the input field in the GUI.
|
boolean |
isEnumeration()
Check if the parameter type enumerates the allowed values
or not.
|
(package private) abstract ParameterValueData<?> |
newParameterValueData()
Create a new
ParameterValueData subclass which is used to
store values of this value type in the database. |
void |
validate(java.lang.String name,
java.util.List<?> values)
Check if a list of values contain invalid values.
|
void |
validate(java.lang.String name,
java.lang.Object value)
Check if a value is valid according to the settings of this parameter type.
|
(package private) abstract void |
validateValue(java.lang.String name,
T value)
Validate a value.
|
private java.util.List<T> items
private Enumeration<T,java.lang.String> enumeration
private boolean checkValues
private final java.lang.Class<T> clazz
private final Type valueType
private final T defaultValue
private final boolean notNull
private final int height
private final int width
private final int multiplicity
ParameterType(Type valueType, java.lang.Class<T> clazz)
clazz
- The class of the parameters that this type holdsParameterType(Type valueType, java.lang.Class<T> clazz, T defaultValue, boolean notNull)
clazz
- The class of the parameters that this type holds.defaultValue
- The parameters default value.notNull
- If the parameter is allowed to be null.ParameterType(Type valueType, java.lang.Class<T> clazz, T defaultValue, boolean notNull, int multiplicity, int width, int height)
ParameterType(Type valueType, java.lang.Class<T> clazz, T defaultValue, boolean notNull, int multiplicity, int width, int height, java.util.List<T> items)
ParameterType(Type valueType, java.lang.Class<T> clazz, T defaultValue, boolean notNull, int multiplicity, int width, int height, Enumeration<T,java.lang.String> enumeration, boolean checkValues)
public Type getValueType()
public java.lang.Class<T> getParameterClass()
public int getHeight()
public int getWidth()
public boolean getNotNull()
public int getMultiplicity()
public T getDefaultValue()
public void validate(java.lang.String name, java.lang.Object value) throws InvalidDataException
name
- The name of the parameter, used for better exception messagesvalue
- The value to testInvalidDataException
- If the value is invalidpublic void validate(java.lang.String name, java.util.List<?> values) throws InvalidDataException
name
- The name of the parameter, used for better exception messages.values
- A list of objects to checkInvalidDataException
- If the list contains too many values as
specified by the getMultiplicity()
setting or has invalid values
as checked by validate(String, Object)
abstract ParameterValueData<?> newParameterValueData()
ParameterValueData
subclass which is used to
store values of this value type in the database.abstract void validateValue(java.lang.String name, T value) throws InvalidDataException
name
- The name of the parameter, use the name if there is need to
throw an exceptionvalue
- The valueInvalidDataException
- If the value is not validpublic boolean isEnumeration()
getItems()
or getEnumeration()
.
NOTE! If an Enumeration
has been supplied the getItems
method will return a list of the keys of the enumeration.public java.util.List<T> getItems()
getEnumeration()
public Enumeration<T,java.lang.String> getEnumeration()
getItems()
in that it has second value attached to each value. The second value
should be used for display purposes only while the first value is
the one that is used.getItems()