public class ParameterSetTagger extends Object
Parameter of ParameterSet. This enable a parameter usage in command line
tool. Argument can be parsed from the specific syntax tag<delimiter>value.
ParameterSet via ParameterSet.getParameterAt(int) only once during creation of
a new instance (in the constructor). If the number of parameters changes after the creation of a specific instance, this
instance will not detect this.| Modifier and Type | Class and Description |
|---|---|
static class |
ParameterSetTagger.KeyEntryComparator<K extends Comparable<K>,V>
|
class |
ParameterSetTagger.RankEntryComparator<K,V>
This class implements a comparator on
Map.Entry where value is a ComparableElement with weight Integer. |
| Constructor and Description |
|---|
ParameterSetTagger(String[] tags,
ParameterSet... sets)
The constructor creates an new instance by collecting and tagging all parameters of the
ParameterSets. |
| Modifier and Type | Method and Description |
|---|---|
void |
fillParameters(String delimiter,
String... args) |
Parameter |
getParameterFromTag(String tag)
This method returns the
Parameter specified by the tag |
Object |
getValueFromTag(String tag)
This method returns the value of the
Parameter specified by the tag. |
<T> T |
getValueFromTag(String tag,
Class<T> c)
This method returns the casted value of the
Parameter specified by the tag. |
boolean |
hasDefaultOrIsSet()
This method allows to check whether all tagged parameters that require a value also have some value.
|
boolean |
isSet(String tag) |
void |
setValueFromTag(String tag,
Object value)
This method allows to easily set the value of a parameter defined by the tag.
|
String |
toString() |
String |
toString(Comparator<Map.Entry<String,ComparableElement<Parameter,Integer>>> ec)
This method allows to get a String representation where the tagged parameters are sorted in some specific way.
|
public ParameterSetTagger(String[] tags, ParameterSet... sets)
ParameterSets.tags - the unambiguous tags for all parameterssets - the sets of ParametersParameterSet.getNumberOfParameters(),
ParameterSet.getParameterAt(int)public void fillParameters(String delimiter, String... args) throws IllegalArgumentException, SimpleParameter.IllegalValueException
delimiter - the delimiter between each tag and valueargs - the arguments, each argument has the form tag<delimiter>valueIllegalArgumentException - if any argument could not be assigned to a parameterSimpleParameter.IllegalValueException - if any argument could not be parsedpublic Parameter getParameterFromTag(String tag)
Parameter specified by the tagtag - the tag of the ParameterParameter specified by the tagParameterSet.getParameterAt(int)public boolean isSet(String tag)
tag - the tag of the Parametertrue if the the parameter is setgetParameterFromTag(String),
Parameter.isSet()public Object getValueFromTag(String tag)
Parameter specified by the tag.tag - the tag of the ParameterParameter specified by the taggetParameterFromTag(String),
AnnotatedEntity.getValue()public <T> T getValueFromTag(String tag, Class<T> c)
Parameter specified by the tag.T - the type of the classtag - the tag of the Parameterc - the class that is used for castingParameter specified by the taggetValueFromTag(String)public void setValueFromTag(String tag, Object value) throws SimpleParameter.IllegalValueException
tag - the tag of the Parametervalue - the value to be setSimpleParameter.IllegalValueException - if the value could not be setgetParameterFromTag(String),
Parameter.setValue(Object)public boolean hasDefaultOrIsSet()
true if each Parameter that requires a value also has a default value or has been setParameter.hasDefaultOrIsSet()public String toString(Comparator<Map.Entry<String,ComparableElement<Parameter,Integer>>> ec)
ec - the comparator for sortingString representation of this instanceParameterSetTagger.KeyEntryComparator,
ParameterSetTagger.RankEntryComparator