Interface NaftahTemporalAmount

All Superinterfaces:
NaftahTemporal
All Known Implementing Classes:
NaftahDuration, NaftahPeriod, NaftahPeriodWithDuration

public sealed interface NaftahTemporalAmount extends NaftahTemporal permits NaftahDuration, NaftahPeriod, NaftahPeriodWithDuration
Represents a temporal amount with a Naftah textual representation.

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:

The following implementations are permitted:

Author:
Chakib Daii
  • 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

      boolean isEquals(NaftahTemporalAmount other)
      Determines whether this temporal amount is equal to the given temporal amount.
      Parameters:
      other - the temporal amount to compare with
      Returns:
      true if the temporal amounts are equal; false otherwise
    • notEquals

      boolean notEquals(NaftahTemporalAmount other)
      Determines whether this temporal amount is not equal to the given temporal amount.
      Parameters:
      other - the temporal amount to compare with
      Returns:
      true if the temporal amounts are not equal; false otherwise
    • greaterThan

      default boolean greaterThan(NaftahTemporalAmount other)
      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:
      true if this temporal amount is greater than the given one
      Throws:
      NaftahBugError - if the operation is not supported
    • greaterThanEquals

      default boolean greaterThanEquals(NaftahTemporalAmount other)
      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:
      true if this temporal amount is greater than or equal to the given one
      Throws:
      NaftahBugError - if the operation is not supported
    • lessThan

      default boolean lessThan(NaftahTemporalAmount other)
      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:
      true if this temporal amount is less than the given one
      Throws:
      NaftahBugError - if the operation is not supported
    • lessThanEquals

      default boolean lessThanEquals(NaftahTemporalAmount other)
      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:
      true if this temporal amount is less than or equal to the given one
      Throws:
      NaftahBugError - if the operation is not supported