Interface NaftahTemporalAmount
- All Superinterfaces:
NaftahTemporal
- All Known Implementing Classes:
NaftahDuration,NaftahPeriod,NaftahPeriodWithDuration
This sealed interface is the common abstraction for all Naftah-aware temporal amounts, such as durations, periods, or a combination of both.
Implementations are responsible for providing both:
- An Naftah textual representation via
Object.toString() - The underlying
TemporalAmountrepresentation
The following implementations are permitted:
NaftahDuration– time-based amounts (hours, minutes, seconds)NaftahPeriod– date-based amounts (years, months, days)NaftahPeriodWithDuration– a combination of period and duration
- Author:
- Chakib Daii
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleangreaterThan(NaftahTemporalAmount other) Determines whether this temporal amount is greater than the given temporal amount.default booleanDetermines whether this temporal amount is greater than or equal to the given temporal amount.booleanisEquals(NaftahTemporalAmount other) Determines whether this temporal amount is equal to the given temporal amount.default booleanlessThan(NaftahTemporalAmount other) Determines whether this temporal amount is less than the given temporal amount.default booleanDetermines whether this temporal amount is less than or equal to the given temporal amount.default NaftahTemporalAmountminus(NaftahTemporalAmount other) Returns a temporal amount obtained by subtracting the given Naftah temporal amount from this one.booleannotEquals(NaftahTemporalAmount other) Determines whether this temporal amount is not equal to the given temporal amount.default NaftahTemporalAmountplus(NaftahTemporalAmount other) Returns a temporal amount obtained by adding the given Naftah temporal amount to this one.Returns the underlying temporal amount represented by this Naftah temporal object.
-
Method Details
-
temporalAmount
TemporalAmount temporalAmount()Returns the underlying temporal amount represented by this Naftah temporal object.- Returns:
- the temporal amount
-
plus
Returns a temporal amount obtained by adding the given Naftah temporal amount to this one.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to add- Returns:
- the resulting
NaftahTemporalAmount - Throws:
NaftahBugError- if the operation is not supported
-
minus
Returns a temporal amount obtained by subtracting the given Naftah temporal amount from this one.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to subtract- Returns:
- the resulting
NaftahTemporalAmount - Throws:
NaftahBugError- if the operation is not supported
-
isEquals
Determines whether this temporal amount is equal to the given temporal amount.- Parameters:
other- the temporal amount to compare with- Returns:
trueif the temporal amounts are equal;falseotherwise
-
notEquals
Determines whether this temporal amount is not equal to the given temporal amount.- Parameters:
other- the temporal amount to compare with- Returns:
trueif the temporal amounts are not equal;falseotherwise
-
greaterThan
Determines whether this temporal amount is greater than the given temporal amount.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to compare with- Returns:
trueif this temporal amount is greater than the given one- Throws:
NaftahBugError- if the operation is not supported
-
greaterThanEquals
Determines whether this temporal amount is greater than or equal to the given temporal amount.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to compare with- Returns:
trueif this temporal amount is greater than or equal to the given one- Throws:
NaftahBugError- if the operation is not supported
-
lessThan
Determines whether this temporal amount is less than the given temporal amount.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to compare with- Returns:
trueif this temporal amount is less than the given one- Throws:
NaftahBugError- if the operation is not supported
-
lessThanEquals
Determines whether this temporal amount is less than or equal to the given temporal amount.The default implementation does not support this operation and always throws an exception.
- Parameters:
other- the temporal amount to compare with- Returns:
trueif this temporal amount is less than or equal to the given one- Throws:
NaftahBugError- if the operation is not supported
-