Class ParameterSet
java.lang.Object
org.opentrafficsim.base.parameters.ParameterSet
- All Implemented Interfaces:
 java.io.Serializable,Parameters
public class ParameterSet extends java.lang.Object implements Parameters, java.io.Serializable
Implementation of 
Parameters with methods to initialize the set of parameters.
 
 Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See OpenTrafficSim License.
 
- Version:
 - $Revision$, $LastChangedDate$, by $Author$, initial version Apr 13, 2016 
 - Author:
 - Alexander Verbraeck, Wouter Schakel
 - See Also:
 - Serialized Form
 
- 
Constructor Summary
Constructors Constructor Description ParameterSet()Construct a new, empty Parameters set.ParameterSet(Parameters parameters)Constructor which creates a copy of the input set. - 
Method Summary
Modifier and Type Method Description booleancontains(ParameterType<?> parameterType)Indicate whether the given parameter type has been set.<T> TgetParameter(ParameterType<T> parameterType)Get parameter of given type.<T> TgetParameterOrNull(ParameterType<T> parameterType)Returns a parameter value, ornullif not present.java.util.Map<ParameterType<?>,java.lang.Object>getParameters()Returns a safe copy of the parameters.voidresetParameter(ParameterType<?> parameterType)Resets the parameter value to the value from before the last set.voidsetAllIn(Parameters params)Sets the parameters of this set in the given set.<T> ParameterSetsetDefaultParameter(ParameterType<T> parameter)Sets the default value of a parameter.ParameterSetsetDefaultParameters(java.lang.Class<?> clazz)Sets the default values of all accessible parameters defined in the given class.<T> voidsetParameter(ParameterType<T> parameterType, T value)Set parameter value of given parameter type.<T> voidsetParameterResettable(ParameterType<T> parameterType, T value)Set parameter value of given parameter type, store old value to allow a reset.java.lang.StringtoString() 
- 
Constructor Details
- 
ParameterSet
public ParameterSet()Construct a new, empty Parameters set. - 
ParameterSet
Constructor which creates a copy of the input set.- Parameters:
 parameters- Parameters; input set to copy into the new Parameters object
 
 - 
 - 
Method Details
- 
setParameter
public final <T> void setParameter(ParameterType<T> parameterType, T value) throws ParameterExceptionSet parameter value of given parameter type.- Specified by:
 setParameterin interfaceParameters- Type Parameters:
 T- Class of value.- Parameters:
 parameterType- ParameterType<T>; the parameter type.value- T; new value for the parameter of typeparameterType.- Throws:
 ParameterException- If the value does not comply with value type constraints.
 - 
setParameterResettable
public final <T> void setParameterResettable(ParameterType<T> parameterType, T value) throws ParameterExceptionSet parameter value of given parameter type, store old value to allow a reset.- Specified by:
 setParameterResettablein interfaceParameters- Type Parameters:
 T- Class of value.- Parameters:
 parameterType- ParameterType<T>; the parameter type.value- T; new value for the parameter of typeparameterType.- Throws:
 ParameterException- If the value does not comply with value type constraints.
 - 
resetParameter
Resets the parameter value to the value from before the last set. This goes only a single value back.- Specified by:
 resetParameterin interfaceParameters- Parameters:
 parameterType- ParameterType<?>; the parameter type.- Throws:
 ParameterException- If the parameter was never set.
 - 
getParameter
Get parameter of given type.- Specified by:
 getParameterin interfaceParameters- Type Parameters:
 T- Class of value.- Parameters:
 parameterType- ParameterType<T>; the parameter type.- Returns:
 - T; parameter of the requested type if it exists
 - Throws:
 ParameterException- If the parameter was never set.
 - 
getParameterOrNull
Returns a parameter value, ornullif not present. This can be used to prevent frequent calls to bothcontains()andgetParameter()in performance critical code.- Specified by:
 getParameterOrNullin interfaceParameters- Type Parameters:
 T- type of parameter value- Parameters:
 parameterType- ParameterType<T>; parameter type- Returns:
 - parameter value, or 
nullif not present 
 - 
contains
Indicate whether the given parameter type has been set.- Specified by:
 containsin interfaceParameters- Parameters:
 parameterType- ParameterType<?>; the parameter type to check- Returns:
 - boolean; true if 
parameterTypehas been set; false ifparameterTypehas not been set 
 - 
getParameters
Returns a safe copy of the parameters.- Returns:
 - Map<AbstractParameterType<?>>; a safe copy of the parameters, e.g., for printing
 
 - 
setDefaultParameter
public final <T> ParameterSet setDefaultParameter(ParameterType<T> parameter) throws ParameterExceptionSets the default value of a parameter. Default value sets are not resettable.- Type Parameters:
 T- Class of the value- Parameters:
 parameter- ParameterType<T>; the parameter to set the default value of- Returns:
 - Parameters; this set of parameters (for method chaining)
 - Throws:
 ParameterException- if the parameter type has no default value
 - 
setDefaultParameters
Sets the default values of all accessible parameters defined in the given class. Default value sets are not resettable.- Parameters:
 clazz- Class<?>; class with parameters- Returns:
 - Parameters; this set of parameters (for method chaining)
 
 - 
setAllIn
Sets the parameters of this set in the given set.- Specified by:
 setAllInin interfaceParameters- Parameters:
 params- Parameters; parameters to set the values in
 - 
toString
public final java.lang.String toString()- Overrides:
 toStringin classjava.lang.Object
 
 -