Class CheckerDuration
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Duration,
CheckerDuration>, Duration>
CheckerDuration is a specialized checker for validating and performing assertions on
Duration
values.
It provides a fluent API for common duration validations such as checking positivity, negativity, zero, and comparisons with other durations or temporal units.
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerDuration
(Duration duration, String name) Constructs a newCheckerDuration
with the specified duration and name. -
Method Summary
Modifier and TypeMethodDescriptionstatic CheckerDuration
Creates a new CheckerDuration instance for the given duration with a default name.static CheckerDuration
Creates 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 CheckerDuration
self()
Returns this instance (for fluent API usage).Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
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:
self
in 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
-