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.StringGLOBAL_RANDOM_STR(package private) java.lang.LongseedSeed 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.StringgetDefaultValueAsString()Get the default value as string.java.lang.StringgetSyntax()Returns a string representation of the parameter's type (e.g., anIntParametershould return<int>).java.lang.StringgetValueAsString()Get the value as string.booleangrab(Parameterization config, java.util.function.Consumer<RandomFactory> consumer)Get the parameter.protected RandomFactoryparseValue(java.lang.Object obj)Parse a given value into the destination type.voidsetValue(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:ParameterReturns a string representation of the parameter's type (e.g., anIntParametershould return<int>).- Returns:
- a string representation of the parameter's type
-
setValue
public void setValue(java.lang.Object obj) throws ParameterExceptionDescription copied from interface:ParameterSets the value of the option.- Specified by:
setValuein interfaceParameter<RandomFactory>- Overrides:
setValuein 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:AbstractParameterParse a given value into the destination type.- Specified by:
parseValuein 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:ParameterGet the value as string. May returnnull- Returns:
- Value as string
-
getDefaultValueAsString
public java.lang.String getDefaultValueAsString()
Description copied from interface:ParameterGet the default value as string.- Specified by:
getDefaultValueAsStringin interfaceParameter<RandomFactory>- Overrides:
getDefaultValueAsStringin 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:
trueif valid
-
-