public interface ConstraintInterface
public class myModel implements ConstraintInterface
{
public static final ParameterTypeLength X = new ParameterTypeLength("x", "My x parameter.", POSITIVE);
// ... model that uses parameter of type X.
}
Another way to access the enum fields is to import them, e.g.:
import static org.opentrafficsim.core.gtu.drivercharacteristics.AbstractParameterType.Constraint.POSITIVE;
public static final ParameterTypeLength X = new ParameterTypeLength("x", "My x parameter.")
{
public void check(Length value, Parameters params) throws ParameterException
{
Throw.when(value.si <= 2, ParameterException.class, "Value of X is not above 2.");
Throw.when(params.contains(Y) && value.si > params.getParameter(Y).si, ParameterException.class,
"Value of X is larger than value of Y.");
}
};
Checks are invoked on default values (if given), in which case an empty Parameters is forwarded. At construction of
a Parameter Type, no Parameters is available. Checks are also invoked when value are set into Parameters,
in which case that Parameters forwards itself. Even still, if in the above case X is set before Y, the check is
never performed. Therefore, Y should also compare itself to X. Two parameters that are checked with each other, should
both implement a check which is consistent with and mirrored to the the others' check.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
| Modifier and Type | Field and Description |
|---|---|
static Constraint<Number> |
ATLEASTONE |
static Constraint<Number> |
NEGATIVE |
static Constraint<Number> |
NEGATIVEZERO |
static Constraint<Number> |
NONZERO |
static Constraint<Number> |
POSITIVE |
static Constraint<Number> |
POSITIVEZERO |
static Constraint<Number> |
UNITINTERVAL |
static final Constraint<Number> POSITIVE
static final Constraint<Number> NEGATIVE
static final Constraint<Number> POSITIVEZERO
static final Constraint<Number> NEGATIVEZERO
static final Constraint<Number> NONZERO
static final Constraint<Number> ATLEASTONE
static final Constraint<Number> UNITINTERVAL
Copyright © 2014–2019 Delft University of Technology. All rights reserved.