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 map
T - the type of parameter stored in the map
All Implemented Interfaces:
Serializable, Cloneable, InputParameter<T,T>
Direct Known Subclasses:
InputParameterDistContinuousSelection, InputParameterDistDiscreteSelection, InputParameterUnit

public class InputParameterSelectionMap<K,T> extends AbstractInputParameter<T,T>
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.
Author:
Alexander Verbraeck
See Also:
  • Constructor Details

    • InputParameterSelectionMap

      public InputParameterSelectionMap(String key, String shortName, String description, SortedMap<K,T> options, T defaultValue, double displayPriority) throws InputParameterException
      Construct a new InputParameterSelectionMap.
      Parameters:
      key - String; unique (within the parent's input parameter map) name of the new InputParameterSelectionMap
      shortName - String; concise description of the input parameter
      description - String; long description of the input parameter (may use HTML markup)
      options - SortedMap<K,T>; the list of selection options
      defaultValue - T; the default value of this input parameter
      displayPriority - double; sorting order when properties are displayed to the user
      Throws:
      NullPointerException - when key, shortName, defaultValue, or description is null
      IllegalArgumentException - when displayPriority is NaN
      InputParameterException - in case the default value is not part of the list
  • Method Details

    • getCalculatedValue

      public T 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

      public SortedMap<K,T> getOptions()
      Returns:
      the options for the selection
    • getKeyforValue

      public K 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

      public K getKeyforValue(T value)
      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

      public void setMapValue(T newValue) throws InputParameterException
      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

      public void setObjectValue(Object objectValue) throws InputParameterException
      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

      public void setKeyforValue(K key) throws InputParameterException
      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

      public InputParameterSelectionMap<K,T> clone()
      Provide the clone() method to make a deep copy.
      Specified by:
      clone in interface InputParameter<K,T>
      Overrides:
      clone in class AbstractInputParameter<T,T>
      Returns:
      a deep copy of the InputParameter