Class InputParameterSelectionMap<K,T>
java.lang.Object
nl.tudelft.simulation.dsol.model.inputparameters.AbstractInputParameter<T,T>
nl.tudelft.simulation.dsol.model.inputparameters.InputParameterSelectionMap<K,T>
- Type Parameters:
K
- the key value to select the values in the mapT
- the type of parameter stored in the map
- All Implemented Interfaces:
Serializable
,Cloneable
,InputParameter<T,
T>
- Direct Known Subclasses:
InputParameterDistContinuousSelection
,InputParameterDistDiscreteSelection
,InputParameterUnit
InputParameterSelectionMap contains a list of key values to select from, each leading to another value to be selected as the
value. An example would be a list of human readable ISO-3166 2-letter country codes to choose from (String), whereas the
ISO3166 numeric code would be stored as an int. The InputParameterSelectionMap extends AbstractInputParameter<T> and
not AbstractInputParameter<Map<K, T>> because the value it can return is the value-item in the map and not
the map itself.
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.
- Author:
- Alexander Verbraeck
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Provide the clone() method to make a deep copy.Retrieve the calculated value of the input parameter.Return the index of the current value.getKeyforValue
(T value) Return the index of the given value in the options.void
setKeyforValue
(K key) Return the index of the given value in the options.void
setMapValue
(T newValue) Set a new value by providing one of the map value options.void
setObjectValue
(Object objectValue) Change the value of the input parameter, as an object when the generics are not known (e.g., in a user interface).Methods inherited from class nl.tudelft.simulation.dsol.model.inputparameters.AbstractInputParameter
getDefaultValue, getDescription, getDisplayPriority, getExtendedKey, getKey, getParent, getShortName, getValue, isReadOnly, setDefaultValue, setParent, setReadOnly, setValue, toString
-
Constructor Details
-
InputParameterSelectionMap
public InputParameterSelectionMap(String key, String shortName, String description, SortedMap<K, T> options, T defaultValue, double displayPriority) throws InputParameterExceptionConstruct a new InputParameterSelectionMap.- Parameters:
key
- String; unique (within the parent's input parameter map) name of the new InputParameterSelectionMapshortName
- String; concise description of the input parameterdescription
- String; long description of the input parameter (may use HTML markup)options
- SortedMap<K,T>; the list of selection optionsdefaultValue
- T; the default value of this input parameterdisplayPriority
- double; sorting order when properties are displayed to the user- Throws:
NullPointerException
- when key, shortName, defaultValue, or description is nullIllegalArgumentException
- when displayPriority is NaNInputParameterException
- in case the default value is not part of the list
-
-
Method Details
-
getCalculatedValue
Retrieve the calculated value of the input parameter. This is often the same as the value type, except in situations where a sub-map or sub-list calculates a different value. This is, for instance, the case with distribution functions where the parameters are present in a sub-map (the value) and the return type of the value is a distribution function class.- Returns:
- CT; the calculated value of the input parameter
-
getOptions
- Returns:
- the options for the selection
-
getKeyforValue
Return the index of the current value.- Returns:
- K; the key in the options belonging to the current value, or null if the list does not contain the value
-
getKeyforValue
Return the index of the given value in the options.- Parameters:
value
- T; the value to calculate the index for- Returns:
- K; the key in the options belonging to the given value, or null if the list does not contain the value
-
setMapValue
Set a new value by providing one of the map value options.- Parameters:
newValue
- T; the new value (must be one of the map value options)- Throws:
InputParameterException
- when the new value is not part of selectionMap options, or when the map is read-only
-
setObjectValue
Change the value of the input parameter, as an object when the generics are not known (e.g., in a user interface).- Parameters:
objectValue
- Object; the new value for the input parameter- Throws:
InputParameterException
- when this InputParameter is read-only, or newValue is not valid
-
setKeyforValue
Return the index of the given value in the options.- Parameters:
key
- K; the index of the new value- Throws:
InputParameterException
- when index out of bounds
-
clone
Provide the clone() method to make a deep copy.- Specified by:
clone
in interfaceInputParameter<K,
T> - Overrides:
clone
in classAbstractInputParameter<T,
T> - Returns:
- a deep copy of the InputParameter
-