Class RandomParameter
- java.lang.Object
-
- elki.utilities.optionhandling.parameters.AbstractParameter<RandomParameter,RandomFactory>
-
- elki.utilities.optionhandling.parameters.RandomParameter
-
- All Implemented Interfaces:
Parameter<RandomFactory>
public class RandomParameter extends AbstractParameter<RandomParameter,RandomFactory>
Parameter for random generators and/or random seeds.- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
GLOBAL_RANDOM_STR
(package private) java.lang.Long
seed
Seed value, if used-
Fields inherited from class elki.utilities.optionhandling.parameters.AbstractParameter
constraints, defaultValue, givenValue, optionalParameter, optionid
-
-
Constructor Summary
Constructors Constructor Description RandomParameter(OptionID optionID)
Constructor without default.RandomParameter(OptionID optionID, RandomFactory defaultValue)
Constructor with default value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDefaultValueAsString()
Get the default value as string.java.lang.String
getSyntax()
Returns a string representation of the parameter's type (e.g., anIntParameter
should return<int>
).java.lang.String
getValueAsString()
Get the value as string.boolean
grab(Parameterization config, java.util.function.Consumer<RandomFactory> consumer)
Get the parameter.protected RandomFactory
parseValue(java.lang.Object obj)
Parse a given value into the destination type.void
setValue(java.lang.Object obj)
Sets the value of the option.-
Methods inherited from class elki.utilities.optionhandling.parameters.AbstractParameter
addConstraint, describeValues, getConstraints, getDefaultValue, getOptionID, getValue, hasDefaultValue, isDefined, isOptional, isValid, setDefaultValue, setOptional, setValueInternal, tookDefaultValue, tryDefaultValue, validate
-
-
-
-
Field Detail
-
GLOBAL_RANDOM_STR
private static final java.lang.String GLOBAL_RANDOM_STR
- See Also:
- Constant Field Values
-
seed
java.lang.Long seed
Seed value, if used
-
-
Constructor Detail
-
RandomParameter
public RandomParameter(OptionID optionID)
Constructor without default.- Parameters:
optionID
- Option ID
-
RandomParameter
public RandomParameter(OptionID optionID, RandomFactory defaultValue)
Constructor with default value. The default value may benull
, which means a new random will be generated.- Parameters:
optionID
- Option IDdefaultValue
- Default value. Ifnull
, a new random object will be created.
-
-
Method Detail
-
getSyntax
public java.lang.String getSyntax()
Description copied from interface:Parameter
Returns a string representation of the parameter's type (e.g., anIntParameter
should return<int>
).- Returns:
- a string representation of the parameter's type
-
setValue
public void setValue(java.lang.Object obj) throws ParameterException
Description copied from interface:Parameter
Sets the value of the option.- Specified by:
setValue
in interfaceParameter<RandomFactory>
- Overrides:
setValue
in classAbstractParameter<RandomParameter,RandomFactory>
- Parameters:
obj
- the option's value to be set- Throws:
ParameterException
- if the given value is not a valid value for this option.
-
parseValue
protected RandomFactory parseValue(java.lang.Object obj) throws ParameterException
Description copied from class:AbstractParameter
Parse a given value into the destination type.- Specified by:
parseValue
in classAbstractParameter<RandomParameter,RandomFactory>
- Parameters:
obj
- Object to parse (may be a string representation!)- Returns:
- Parsed object
- Throws:
ParameterException
- when the object cannot be parsed.
-
getValueAsString
public java.lang.String getValueAsString()
Description copied from interface:Parameter
Get the value as string. May returnnull
- Returns:
- Value as string
-
getDefaultValueAsString
public java.lang.String getDefaultValueAsString()
Description copied from interface:Parameter
Get the default value as string.- Specified by:
getDefaultValueAsString
in interfaceParameter<RandomFactory>
- Overrides:
getDefaultValueAsString
in classAbstractParameter<RandomParameter,RandomFactory>
- Returns:
- default value
-
grab
public boolean grab(Parameterization config, java.util.function.Consumer<RandomFactory> consumer)
Get the parameter.- Parameters:
config
- Parameterizationconsumer
- Output consumer- Returns:
true
if valid
-
-