summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2019-03-09 22:30:34 +0000
committerAndrej Shadura <andrewsh@debian.org>2019-03-09 22:30:34 +0000
commitb7b404fd7a726774d442562d11659d7b5368cdb9 (patch)
tree6f510ddbf80c1a51e333f80411541565ac71c9e9 /src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java
parentace5fa7f57d49756c0e1b111a30f3b6a9436c1cb (diff)
Import Upstream version 0.5.5
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java')
-rw-r--r--src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java91
1 files changed, 11 insertions, 80 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java
index 6f1a7beb..ac8bd62c 100644
--- a/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java
+++ b/src/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/LongParameter.java
@@ -23,8 +23,6 @@ package de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters;
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import java.util.List;
-
import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException;
@@ -42,69 +40,14 @@ public class LongParameter extends NumberParameter<Long> {
* and default value.
*
* @param optionID the unique OptionID for this parameter
- * @param constraints the parameter constraints for this long parameter
- * @param defaultValue the default value
- */
- public LongParameter(OptionID optionID, List<ParameterConstraint<Number>> constraints, long defaultValue) {
- super(optionID, constraints, defaultValue);
- }
-
- /**
- * Constructs a long parameter with the given optionID, and parameter
- * constraint.
- *
- * @param optionID the unique OptionID for this parameter
- * @param constraints the parameter constraints for this long parameter
- * @param optional optional flag
- */
- public LongParameter(OptionID optionID, List<ParameterConstraint<Number>> constraints, boolean optional) {
- super(optionID, constraints, optional);
- }
-
- /**
- * Constructs a long parameter with the given optionID, and parameter
- * constraint.
- *
- * @param optionID the unique OptionID for this parameter
- * @param constraints the parameter constraints for this long parameter
- */
- public LongParameter(OptionID optionID, List<ParameterConstraint<Number>> constraints) {
- super(optionID, constraints);
- }
-
- /**
- * Constructs a long parameter with the given optionID, parameter constraint
- * and default value.
- *
- * @param optionID the unique OptionID for this parameter
* @param constraint the parameter constraint for this long parameter
* @param defaultValue the default value
+ * @deprecated Use {@link #addConstraint} instead!
*/
+ @Deprecated
public LongParameter(OptionID optionID, ParameterConstraint<Number> constraint, long defaultValue) {
- super(optionID, constraint, defaultValue);
- }
-
- /**
- * Constructs a long parameter with the given optionID, and parameter
- * constraint.
- *
- * @param optionID the unique OptionID for this parameter
- * @param constraint the parameter constraint for this long parameter
- * @param optional optional flag
- */
- public LongParameter(OptionID optionID, ParameterConstraint<Number> constraint, boolean optional) {
- super(optionID, constraint, optional);
- }
-
- /**
- * Constructs a long parameter with the given optionID, and parameter
- * constraint.
- *
- * @param optionID the unique OptionID for this parameter
- * @param constraint the parameter constraint for this long parameter
- */
- public LongParameter(OptionID optionID, ParameterConstraint<Number> constraint) {
- super(optionID, constraint);
+ super(optionID, Long.valueOf(defaultValue));
+ addConstraint(constraint);
}
/**
@@ -114,17 +57,7 @@ public class LongParameter extends NumberParameter<Long> {
* @param defaultValue the default value
*/
public LongParameter(OptionID optionID, long defaultValue) {
- super(optionID, defaultValue);
- }
-
- /**
- * Constructs a long parameter with the given optionID.
- *
- * @param optionID the unique OptionID for this parameter
- * @param optional optional flag
- */
- public LongParameter(OptionID optionID, boolean optional) {
- super(optionID, optional);
+ super(optionID, Long.valueOf(defaultValue));
}
/**
@@ -136,29 +69,27 @@ public class LongParameter extends NumberParameter<Long> {
super(optionID);
}
- /** {@inheritDoc} */
@Override
public String getValueAsString() {
- return Long.toString(getValue());
+ return getValue().toString();
}
- /** {@inheritDoc} */
@Override
protected Long parseValue(Object obj) throws ParameterException {
if(obj instanceof Long) {
return (Long) obj;
}
- if(obj instanceof Integer) {
- return new Long((Integer) obj);
+ if(obj instanceof Number) {
+ return Long.valueOf(((Number) obj).longValue());
}
try {
- return Long.parseLong(obj.toString());
+ return Long.valueOf(obj.toString());
}
catch(NullPointerException e) {
- throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a double value, read: " + obj + "!\n");
+ throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a long value, read: " + obj + "!\n");
}
catch(NumberFormatException e) {
- throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a double value, read: " + obj + "!\n");
+ throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a long value, read: " + obj + "!\n");
}
}