diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java | 96 |
1 files changed, 14 insertions, 82 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java index ad0ded5c..e71a744e 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ListParameter.java @@ -23,20 +23,20 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters; along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID; -import de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ParameterConstraint; - import java.util.List; import java.util.regex.Pattern; +import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID; + /** * Abstract parameter class defining a parameter for a list of objects. * * @author Steffi Wanka * @author Erich Schubert + * * @param <T> List type */ -public abstract class ListParameter<T> extends Parameter<List<T>, List<T>> { +public abstract class ListParameter<T> extends AbstractParameter<List<T>> { /** * A pattern defining a ",". */ @@ -51,7 +51,7 @@ public abstract class ListParameter<T> extends Parameter<List<T>, List<T>> { * A pattern defining a ":". */ public static final Pattern VECTOR_SPLIT = Pattern.compile(":"); - + /** * Vector separator character - ":" */ @@ -61,79 +61,11 @@ public abstract class ListParameter<T> extends Parameter<List<T>, List<T>> { * Constructs a list parameter with the given optionID. * * @param optionID the unique id of this parameter - * @param constraints the constraints of this parameter, may be null * @param defaultValue the default value of this parameter (may be null) */ - public ListParameter(OptionID optionID, List<ParameterConstraint<List<T>>> constraints, List<T> defaultValue) { - super(optionID, constraints, defaultValue); - } - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param constraints the constraints of this parameter, may be null - * @param optional specifies if this parameter is an optional parameter - */ - public ListParameter(OptionID optionID, List<ParameterConstraint<List<T>>> constraints, boolean optional) { - super(optionID, constraints, optional); - } - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param constraints the constraint of this parameter - */ - // NOTE: we cannot have this, because it has the same erasure as optionID, defaults! - // Use optional=false! - /*public ListParameter(OptionID optionID, List<ParameterConstraint<List<T>>> constraints) { - super(optionID, constraints); - }*/ - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param constraint the constraint of this parameter, may be null - * @param defaultValue the default value of this parameter (may be null) - */ - public ListParameter(OptionID optionID, ParameterConstraint<List<T>> constraint, List<T> defaultValue) { - super(optionID, constraint, defaultValue); - } - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param constraint the constraint of this parameter, may be null - * @param optional specifies if this parameter is an optional parameter - */ - public ListParameter(OptionID optionID, ParameterConstraint<List<T>> constraint, boolean optional) { - super(optionID, constraint, optional); - } - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param constraint the constraint of this parameter - */ - public ListParameter(OptionID optionID, ParameterConstraint<List<T>> constraint) { - super(optionID, constraint); - } - - /** - * Constructs a list parameter with the given optionID. - * - * @param optionID the unique id of this parameter - * @param defaultValue the default value of this parameter (may be null) - */ - // NOTE: we cannot have this, because it has the same erasure as optionID, defaults! - // Use full constructor, constraints = null! - /*public ListParameter(OptionID optionID, List<T> defaultValue) { + public ListParameter(OptionID optionID, List<T> defaultValue) { super(optionID, defaultValue); - }*/ + } /** * Constructs a list parameter with the given optionID and optional flag. @@ -160,7 +92,7 @@ public abstract class ListParameter<T> extends Parameter<List<T>, List<T>> { * @return the size of this list parameter. */ public int getListSize() { - if(getValue() == null && isOptional()) { + if (getValue() == null && isOptional()) { return 0; } @@ -173,19 +105,19 @@ public abstract class ListParameter<T> extends Parameter<List<T>, List<T>> { */ // TODO: keep? remove? protected String asString() { - if(getValue() == null) { + if (getValue() == null) { return ""; } StringBuilder buffer = new StringBuilder(); - buffer.append("["); + buffer.append('['); - for(int i = 0; i < getValue().size(); i++) { + for (int i = 0; i < getValue().size(); i++) { buffer.append(getValue().get(i).toString()); - if(i != getValue().size() - 1) { - buffer.append(","); + if (i != getValue().size() - 1) { + buffer.append(','); } } - buffer.append("]"); + buffer.append(']'); return buffer.toString(); } } |