public interface CheckInterface
public class myModel implements CheckInterface
{
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.Check.POSITIVE;
public static final ParameterTypeLength X = new ParameterTypeLength("x", "My x parameter.")
{
public void check(Length value, BehavioralCharacteristics bc) throws ParameterException
{
Throw.when(value.si <= 2, ParameterException.class, "Value of X is not above 2.");
Throw.when(bc.contains(Y) && value.si > bc.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 BehavioralCharacteristics is forwarded. At
construction of a Parameter Type, no BehavioralCharacteristics is available. Checks are also invoked when value are
set into BehavioralCharacteristics, in which case that BehavioralCharacteristics 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-2016 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 AbstractParameterType.Check |
NEGATIVE |
static AbstractParameterType.Check |
NEGATIVEZERO |
static AbstractParameterType.Check |
NONZERO |
static AbstractParameterType.Check |
POSITIVE |
static AbstractParameterType.Check |
POSITIVEZERO |
static AbstractParameterType.Check |
UNITINTERVAL |
static final AbstractParameterType.Check POSITIVE
static final AbstractParameterType.Check NEGATIVE
static final AbstractParameterType.Check POSITIVEZERO
static final AbstractParameterType.Check NEGATIVEZERO
static final AbstractParameterType.Check NONZERO
static final AbstractParameterType.Check UNITINTERVAL
Copyright © 2014–2016 Delft University of Technology. All rights reserved.