Class DualBound<T extends Number>
java.lang.Object
org.opentrafficsim.base.parameters.constraint.SingleBound<T>
org.opentrafficsim.base.parameters.constraint.DualBound<T>
- Type Parameters:
T- value type
- All Implemented Interfaces:
Constraint<T>
Continuous constraints with a dual bound. To allow both
Double and DoubleScalar<?, ?> constraints, the
generic type is restricted to Number. However, that also allows other subclasses of Number, e.g.
Integer. Due to rounding and value limits from the type (e.g. Integer.MAX_VALEU), bounds may not function
correctly after a call to Number.doubleValue(). To restrict the usage, the constructor is private and static factory
methods for Double and DoubleScalar<?, ?> are supplied.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opentrafficsim.base.parameters.constraint.SingleBound
SingleBound.Bound, SingleBound.LowerBoundExclusive<T extends Number>, SingleBound.LowerBoundInclusive<T extends Number>, SingleBound.UpperBoundExclusive<T extends Number>, SingleBound.UpperBoundInclusive<T extends Number> -
Field Summary
FieldsModifier and TypeFieldDescriptionStandard dual bound on the unit interval [0...1]. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the value complies with constraints.closed(double lowerBound, double upperBound) Creates a dual bound including the bounds;lowerBound <= value <= upperBound.static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>>
DualBound<T>closed(T lowerBound, T upperBound) Creates a dual bound including the bounds;lowerBound <= value <= upperBound.leftClosedRightOpen(double lowerBound, double upperBound) Creates a dual bound including the lower bound and excluding the upper bound;lowerBound <= value < upperBound.static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>>
DualBound<T>leftClosedRightOpen(T lowerBound, T upperBound) Creates a dual bound including the lower bound and excluding the upper bound;lowerBound <= value < upperBound.leftOpenRightClosed(double lowerBound, double upperBound) Creates a dual bound excluding the lower bound and including the upper bound;lowerBound < value <= upperBound.static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>>
DualBound<T>leftOpenRightClosed(T lowerBound, T upperBound) Creates a dual bound excluding the lower bound and including the upper bound;lowerBound < value <= upperBound.open(double lowerBound, double upperBound) Creates a dual bound excluding the bounds;lowerBound < value < upperBound.static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>>
DualBound<T>open(T lowerBound, T upperBound) Creates a dual bound excluding the bounds;lowerBound < value < upperBound.toString()Methods inherited from class org.opentrafficsim.base.parameters.constraint.SingleBound
failMessage, getBound, lowerExclusive, lowerExclusive, lowerInclusive, lowerInclusive, upperExclusive, upperExclusive, upperInclusive, upperInclusive
-
Field Details
-
UNITINTERVAL
Standard dual bound on the unit interval [0...1]. This can be used for bothDoubleandDoubleScalar<?, ?>parameters.
-
-
Method Details
-
closed
Creates a dual bound including the bounds;lowerBound <= value <= upperBound. Bounds may be equal.- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- closed dual bound
-
closed
public static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> DualBound<T> closed(T lowerBound, T upperBound) Creates a dual bound including the bounds;lowerBound <= value <= upperBound.- Type Parameters:
T- value type- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- closed dual bound
-
open
Creates a dual bound excluding the bounds;lowerBound < value < upperBound.- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- open dual bound
-
open
public static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> DualBound<T> open(T lowerBound, T upperBound) Creates a dual bound excluding the bounds;lowerBound < value < upperBound.- Type Parameters:
T- value type- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- open dual bound
-
leftOpenRightClosed
Creates a dual bound excluding the lower bound and including the upper bound;lowerBound < value <= upperBound.- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- excluding the lower bound and including the upper bound
-
leftOpenRightClosed
public static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> DualBound<T> leftOpenRightClosed(T lowerBound, T upperBound) Creates a dual bound excluding the lower bound and including the upper bound;lowerBound < value <= upperBound.- Type Parameters:
T- value type- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- excluding the lower bound and including the upper bound
-
leftClosedRightOpen
Creates a dual bound including the lower bound and excluding the upper bound;lowerBound <= value < upperBound.- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- including the lower bound and excluding the upper bound
-
leftClosedRightOpen
public static <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> DualBound<T> leftClosedRightOpen(T lowerBound, T upperBound) Creates a dual bound including the lower bound and excluding the upper bound;lowerBound <= value < upperBound.- Type Parameters:
T- value type- Parameters:
lowerBound- lower bound valueupperBound- upper bound value- Returns:
- including the lower bound and excluding the upper bound
-
accept
Description copied from interface:ConstraintChecks whether the value complies with constraints.- Specified by:
acceptin interfaceConstraint<T extends Number>- Overrides:
acceptin classSingleBound<T extends Number>- Parameters:
value- Value to check.- Returns:
- Whether the value complies with constraints.
-
toString
- Overrides:
toStringin classSingleBound<T extends Number>
-