Class SingleBound<T extends Number>
java.lang.Object
org.opentrafficsim.base.parameters.constraint.SingleBound<T>
- Type Parameters:
T
- value type
- All Implemented Interfaces:
Constraint<T>
- Direct Known Subclasses:
DualBound
Continuous constraints with a single 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
Modifier and TypeClassDescription(package private) static class
Super class for classes that implement a specific numeric check.(package private) static class
SingleBound.LowerBoundExclusive<T extends Number>
Class implementing a lower exclusive bound;value > bound
.(package private) static class
SingleBound.LowerBoundInclusive<T extends Number>
Class implementing a lower inclusive bound;value >= bound
.(package private) static class
SingleBound.UpperBoundExclusive<T extends Number>
Class implementing an upper exclusive bound;value < bound
.(package private) static class
SingleBound.UpperBoundInclusive<T extends Number>
Class implementing an upper inclusive bound;value <= bound
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether the value complies with constraints.Returns a message for value failure, pointing to a parameter using '%s'.getBound()
static final SingleBound<Double>
lowerExclusive
(double bound) Creates a lower exclusive bound;value > bound
.static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,
?>>
SingleBound<T>lowerExclusive
(T bound) Creates a lower exclusive bound;value > bound
.static final SingleBound<Double>
lowerInclusive
(double bound) Creates a lower inclusive bound;value >= bound
.static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,
?>>
SingleBound<T>lowerInclusive
(T bound) Creates a lower inclusive bound;value >= bound
.toString()
static final SingleBound<Double>
upperExclusive
(double bound) Creates an upper exclusive bound;value < bound
.static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,
?>>
SingleBound<T>upperExclusive
(T bound) Creates an upper exclusive bound;value < bound
.static final SingleBound<Double>
upperInclusive
(double bound) Creates an upper inclusive bound;value <= bound
.static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,
?>>
SingleBound<T>upperInclusive
(T bound) Creates an upper inclusive bound;value <= bound
.
-
Constructor Details
-
SingleBound
SingleBound(SingleBound.Bound bound, String failMessage) Constructor.- Parameters:
bound
- Bound; boundfailMessage
- String; message about values that do not comply with the bound
-
-
Method Details
-
lowerInclusive
Creates a lower inclusive bound;value >= bound
.- Parameters:
bound
- double; bound value- Returns:
- lower inclusive bound
-
lowerInclusive
public static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> SingleBound<T> lowerInclusive(T bound) Creates a lower inclusive bound;value >= bound
.- Type Parameters:
T
- value type- Parameters:
bound
- T; bound value- Returns:
- lower inclusive bound
-
lowerExclusive
Creates a lower exclusive bound;value > bound
.- Parameters:
bound
- double; bound value- Returns:
- lower exclusive bound
-
lowerExclusive
public static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> SingleBound<T> lowerExclusive(T bound) Creates a lower exclusive bound;value > bound
.- Type Parameters:
T
- value type- Parameters:
bound
- T; bound value- Returns:
- lower exclusive bound
-
upperInclusive
Creates an upper inclusive bound;value <= bound
.- Parameters:
bound
- double; bound value- Returns:
- upper inclusive bound
-
upperInclusive
public static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> SingleBound<T> upperInclusive(T bound) Creates an upper inclusive bound;value <= bound
.- Type Parameters:
T
- value type- Parameters:
bound
- T; bound value- Returns:
- upper inclusive bound
-
upperExclusive
Creates an upper exclusive bound;value < bound
.- Parameters:
bound
- double; bound value- Returns:
- upper exclusive bound
-
upperExclusive
public static final <T extends org.djunits.value.vdouble.scalar.base.DoubleScalar<?,?>> SingleBound<T> upperExclusive(T bound) Creates an upper exclusive bound;value < bound
.- Type Parameters:
T
- value type- Parameters:
bound
- T; bound value- Returns:
- upper exclusive bound
-
accept
Checks whether the value complies with constraints.- Specified by:
accept
in interfaceConstraint<T extends Number>
- Parameters:
value
- T; Value to check.- Returns:
- Whether the value complies with constraints.
-
failMessage
Returns a message for value failure, pointing to a parameter using '%s'.- Specified by:
failMessage
in interfaceConstraint<T extends Number>
- Returns:
- Message for value failure, pointing to a parameter using '%s'.
-
getBound
- Returns:
- bound.
-
toString
-