Class CheckerDuration
java.lang.Object
com.luchersol.core.util.AbstractChecker<Duration,CheckerDuration>
com.luchersol.core.specialized_checkers.time.CheckerDuration
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Duration,CheckerDuration>, Duration>
A specialized checker for
Duration instances, providing fluent API methods
to assert various temporal properties such as positivity, negativity, zero value,
and comparisons with other durations or specific temporal units.
Typical usage:
Duration d1 = Duration.ofMinutes(5);
Duration d2 = Duration.ofMinutes(10);
CheckerDuration checker = CheckerDuration.check(d1)
.isPositive()
.isLessThan(d2)
.isGreaterOrEqualThan(Duration.ofMinutes(3));
This class supports chaining multiple assertions in a fluent style and integrates
with AbstractChecker for generalized validation handling.
- See Also:
-
Field Summary
Fields inherited from class com.luchersol.core.util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCheckerDuration(Duration duration, String name) Constructs a newCheckerDurationwith the specified duration and name. -
Method Summary
Modifier and TypeMethodDescriptionstatic CheckerDurationCreates a new CheckerDuration instance for the given duration with a default name.static CheckerDurationCreates a new CheckerDuration instance for the given duration and name.Checks if the duration is equal to another duration.isEqual(TemporalUnit temporalUnit, double time) Checks if the duration is equal to the specified time in the given temporal unit.isGreaterOrEqualThan(Duration other) Checks if the duration is greater than or equal to another duration.isGreaterOrEqualThan(TemporalUnit temporalUnit, double time) Checks if the duration is greater than or equal to the specified time in the given temporal unit.isGreaterThan(Duration other) Checks if the duration is greater than another duration.isGreaterThan(TemporalUnit temporalUnit, double time) Checks if the duration is greater than the specified time in the given temporal unit.isLessOrEqualThan(Duration other) Checks if the duration is less than or equal to another duration.isLessOrEqualThan(TemporalUnit temporalUnit, double time) Checks if the duration is less than or equal to the specified time in the given temporal unit.isLessThan(Duration other) Checks if the duration is less than another duration.isLessThan(TemporalUnit temporalUnit, double time) Checks if the duration is less than the specified time in the given temporal unit.Checks if the duration is negative (less than zero).Checks if the duration is positive (greater than zero).isZero()Checks if the duration is zero.protected CheckerDurationself()Returns this instance (for fluent API usage).Methods inherited from class com.luchersol.core.util.AbstractChecker
checkProperty, checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, setBackObject, setExceptionTracker, setName, setObject, setSaveErrors, setStop, show, showPassedChecks, showThrownException, stop, toChecker, updateChecker
-
Constructor Details
-
CheckerDuration
-
-
Method Details
-
check
Creates a new CheckerDuration instance for the given duration and name.- Parameters:
duration- the duration value to be checkedname- the name to identify the duration in error messages- Returns:
- a CheckerDuration instance for further validations
-
check
Creates a new CheckerDuration instance for the given duration with a default name.- Parameters:
duration- the duration value to be checked- Returns:
- a CheckerDuration instance for further validations
-
self
Returns this instance (for fluent API usage).- Specified by:
selfin classAbstractChecker<Duration,CheckerDuration> - Returns:
- this CheckerDuration instance
-
isPositive
Checks if the duration is positive (greater than zero).- Returns:
- this CheckerDuration instance for chaining
-
isNegative
Checks if the duration is negative (less than zero).- Returns:
- this CheckerDuration instance for chaining
-
isZero
Checks if the duration is zero.- Returns:
- this CheckerDuration instance for chaining
-
isGreaterThan
Checks if the duration is greater than the specified time in the given temporal unit.- Parameters:
temporalUnit- the unit of time to compare (e.g., SECONDS, MINUTES)time- the value to compare against- Returns:
- this CheckerDuration instance for chaining
-
isGreaterOrEqualThan
Checks if the duration is greater than or equal to the specified time in the given temporal unit.- Parameters:
temporalUnit- the unit of time to compare (e.g., SECONDS, MINUTES)time- the value to compare against- Returns:
- this CheckerDuration instance for chaining
-
isLessThan
Checks if the duration is less than the specified time in the given temporal unit.- Parameters:
temporalUnit- the unit of time to compare (e.g., SECONDS, MINUTES)time- the value to compare against- Returns:
- this CheckerDuration instance for chaining
-
isLessOrEqualThan
Checks if the duration is less than or equal to the specified time in the given temporal unit.- Parameters:
temporalUnit- the unit of time to compare (e.g., SECONDS, MINUTES)time- the value to compare against- Returns:
- this CheckerDuration instance for chaining
-
isEqual
Checks if the duration is equal to the specified time in the given temporal unit.- Parameters:
temporalUnit- the unit of time to compare (e.g., SECONDS, MINUTES)time- the value to compare against- Returns:
- this CheckerDuration instance for chaining
-
isGreaterThan
Checks if the duration is greater than another duration.- Parameters:
other- the other duration to compare with- Returns:
- this CheckerDuration instance for chaining
-
isGreaterOrEqualThan
Checks if the duration is greater than or equal to another duration.- Parameters:
other- the other duration to compare with- Returns:
- this CheckerDuration instance for chaining
-
isLessThan
Checks if the duration is less than another duration.- Parameters:
other- the other duration to compare with- Returns:
- this CheckerDuration instance for chaining
-
isLessOrEqualThan
Checks if the duration is less than or equal to another duration.- Parameters:
other- the other duration to compare with- Returns:
- this CheckerDuration instance for chaining
-
isEqual
Checks if the duration is equal to another duration.- Parameters:
other- the other duration to compare with- Returns:
- this CheckerDuration instance for chaining
-