Class ObjectListParameter<C>
- java.lang.Object
-
- elki.utilities.optionhandling.parameters.AbstractParameter<P,T>
-
- elki.utilities.optionhandling.parameters.ListParameter<ClassListParameter<C>,java.util.List<java.lang.Class<? extends C>>>
-
- elki.utilities.optionhandling.parameters.ClassListParameter<C>
-
- elki.utilities.optionhandling.parameters.ObjectListParameter<C>
-
- Type Parameters:
C
- Class type
- All Implemented Interfaces:
Parameter<java.util.List<java.lang.Class<? extends C>>>
public class ObjectListParameter<C> extends ClassListParameter<C>
Parameter that represents a list of objects (in contrast to a class list parameter, they will be instanced at most once.)- Since:
- 0.3
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<C>
instances
Cache for the generated instances.-
Fields inherited from class elki.utilities.optionhandling.parameters.ClassListParameter
restrictionClass
-
Fields inherited from class elki.utilities.optionhandling.parameters.ListParameter
LIST_SEP, SPLIT, VECTOR_SEP, VECTOR_SPLIT
-
Fields inherited from class elki.utilities.optionhandling.parameters.AbstractParameter
constraints, defaultValue, givenValue, optionalParameter, optionid
-
-
Constructor Summary
Constructors Constructor Description ObjectListParameter(OptionID optionID, java.lang.Class<?> restrictionClass)
Constructor for non-optional.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getSyntax()
Returns a string representation of the parameter's type.java.util.List<C>
instantiateClasses(Parameterization config)
Returns a list of new instances for the value (i.e., the class name) of this class list parameter.protected java.util.List<java.lang.Class<? extends C>>
parseValue(java.lang.Object obj)
Parse a given value into the destination type.ObjectListParameter<C>
setOptional(boolean opt)
Specifies if this parameter is an optional parameter.-
Methods inherited from class elki.utilities.optionhandling.parameters.ClassListParameter
describeValues, formatValue, getDefaultValueAsString, getKnownImplementations, getRestrictionClass, getValueAsString, grab, size, validate
-
Methods inherited from class elki.utilities.optionhandling.parameters.AbstractParameter
addConstraint, getConstraints, getDefaultValue, getOptionID, getValue, hasDefaultValue, isDefined, isOptional, isValid, setDefaultValue, setValue, setValueInternal, tookDefaultValue, tryDefaultValue
-
-
-
-
Field Detail
-
instances
private java.util.List<C> instances
Cache for the generated instances.
-
-
Constructor Detail
-
ObjectListParameter
public ObjectListParameter(OptionID optionID, java.lang.Class<?> restrictionClass)
Constructor for non-optional.- Parameters:
optionID
- Option IDrestrictionClass
- Restriction class
-
-
Method Detail
-
getSyntax
public java.lang.String getSyntax()
Description copied from class:ClassListParameter
Returns a string representation of the parameter's type.
-
parseValue
protected java.util.List<java.lang.Class<? extends C>> parseValue(java.lang.Object obj) throws ParameterException
Description copied from class:AbstractParameter
Parse a given value into the destination type.- Overrides:
parseValue
in classClassListParameter<C>
- Parameters:
obj
- Object to parse (may be a string representation!)- Returns:
- Parsed object
- Throws:
ParameterException
- when the object cannot be parsed.
-
setOptional
public ObjectListParameter<C> setOptional(boolean opt)
Description copied from interface:Parameter
Specifies if this parameter is an optional parameter.- Specified by:
setOptional
in interfaceParameter<C>
- Overrides:
setOptional
in classAbstractParameter<ClassListParameter<C>,java.util.List<java.lang.Class<? extends C>>>
- Parameters:
opt
- true if this parameter is optional, false otherwise- Returns:
- the parameter itself, for chaining
-
instantiateClasses
public java.util.List<C> instantiateClasses(Parameterization config)
Description copied from class:ClassListParameter
Returns a list of new instances for the value (i.e., the class name) of this class list parameter. The instances have the type of the restriction class of this class list parameter.If the Class for the class names is not found, the instantiation is tried using the package of the restriction class as package of the class name.
- Overrides:
instantiateClasses
in classClassListParameter<C>
- Parameters:
config
- Parameterization to use (if Parameterizable))- Returns:
- a list of new instances for the value of this class list parameter
-
-