C
- Class typepublic class ClassParameter<C> extends AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
Modifier and Type | Field and Description |
---|---|
private static Logging |
LOG
The class logger.
|
protected java.lang.Class<C> |
restrictionClass
The restriction class for this class parameter.
|
constraints, defaultValue, givenValue, optionalParameter, optionid, shortDescription
Constructor and Description |
---|
ClassParameter(OptionID optionID,
java.lang.Class<?> restrictionClass)
Constructs a class parameter with the given optionID, and restriction
class.
|
ClassParameter(OptionID optionID,
java.lang.Class<?> restrictionClass,
boolean optional)
Constructs a class parameter with the given optionID, restriction class,
and optional flag.
|
ClassParameter(OptionID optionID,
java.lang.Class<?> restrictionClass,
java.lang.Class<?> defaultValue)
Constructs a class parameter with the given optionID, restriction class,
and default value.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
canonicalClassName(java.lang.Class<?> c,
java.lang.Class<?> parent)
Get the "simple" form of a class name.
|
static java.lang.String |
canonicalClassName(java.lang.Class<?> c,
java.lang.Package pkg)
Get the "simple" form of a class name.
|
java.lang.StringBuilder |
describeValues(java.lang.StringBuilder info)
Describe the valid values.
|
java.lang.String |
getDefaultValueAsString()
Get the default value as string.
|
java.util.List<java.lang.Class<?>> |
getKnownImplementations()
Get an iterator over all known implementations of the class restriction.
|
java.lang.Class<C> |
getRestrictionClass()
Returns the restriction class of this class parameter.
|
java.lang.String |
getSyntax()
Returns a string representation of the parameter's type.
|
java.lang.String |
getValueAsString()
Get the value as string.
|
C |
instantiateClass(Parameterization config)
Returns a new instance for the value (i.e., the class name) of this class
parameter.
|
protected java.lang.Class<? extends C> |
parseValue(java.lang.Object obj)
Parse a given value into the destination type.
|
boolean |
validate(java.lang.Class<? extends C> obj)
Checks if the given parameter value is valid for this ClassParameter.
|
addConstraint, getConstraints, getDefaultValue, getOptionID, getShortDescription, getValue, hasDefaultValue, isDefined, isOptional, isValid, setDefaultValue, setOptional, setShortDescription, setValue, setValueInternal, tookDefaultValue, tryDefaultValue
private static final Logging LOG
protected java.lang.Class<C> restrictionClass
public ClassParameter(OptionID optionID, java.lang.Class<?> restrictionClass, java.lang.Class<?> defaultValue)
optionID
- the unique id of the optionrestrictionClass
- the restriction class of this class parameterdefaultValue
- the default value of this class parameterpublic ClassParameter(OptionID optionID, java.lang.Class<?> restrictionClass, boolean optional)
optionID
- the unique id of the optionrestrictionClass
- the restriction class of this class parameteroptional
- specifies if this parameter is an optional parameterpublic ClassParameter(OptionID optionID, java.lang.Class<?> restrictionClass)
optionID
- the unique id of the optionrestrictionClass
- the restriction class of this class parameterprotected java.lang.Class<? extends C> parseValue(java.lang.Object obj) throws ParameterException
AbstractParameter
parseValue
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
obj
- Object to parse (may be a string representation!)ParameterException
- when the object cannot be parsed.public boolean validate(java.lang.Class<? extends C> obj) throws ParameterException
validate
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
obj
- Object to validateParameterException
- when the object is not valid.public java.lang.String getSyntax()
getSyntax
in interface Parameter<java.lang.Class<? extends C>>
getSyntax
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
public java.lang.StringBuilder describeValues(java.lang.StringBuilder info)
Parameter
describeValues
in interface Parameter<java.lang.Class<? extends C>>
describeValues
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
info
- Buffer to append topublic java.lang.String getValueAsString()
Parameter
null
getValueAsString
in interface Parameter<java.lang.Class<? extends C>>
getValueAsString
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
public java.lang.String getDefaultValueAsString()
Parameter
getDefaultValueAsString
in interface Parameter<java.lang.Class<? extends C>>
getDefaultValueAsString
in class AbstractParameter<ClassParameter<C>,java.lang.Class<? extends C>>
public static java.lang.String canonicalClassName(java.lang.Class<?> c, java.lang.Package pkg)
c
- Classpkg
- Packagepublic static java.lang.String canonicalClassName(java.lang.Class<?> c, java.lang.Class<?> parent)
c
- Class nameparent
- Parent/restriction class (to get package name to strip)public C instantiateClass(Parameterization config)
If the Class for the class name is not found, the instantiation is tried using the package of the restriction class as package of the class name.
config
- Parameterization to use (if Parameterizable))public java.lang.Class<C> getRestrictionClass()
public java.util.List<java.lang.Class<?>> getKnownImplementations()
Copyright © 2019 ELKI Development Team. License information.