Class BasicExpiringValue<T>

  • Type Parameters:
    T - The value type.
    All Implemented Interfaces:
    ExpiringValue<T>

    public class BasicExpiringValue<T>
    extends Object
    implements ExpiringValue<T>
    A base class for implementing an expiring value.
    • Constructor Detail

      • BasicExpiringValue

        public BasicExpiringValue​(T value,
                                  Instant expirationTime)
        Creates a new instance for a value and an expiration time.
        Parameters:
        value - The value.
        expirationTime - The instant after which the value will be considered expired.
    • Method Detail

      • isExpired

        public boolean isExpired()
        Description copied from interface: ExpiringValue
        Checks if the value has already expired.
        Specified by:
        isExpired in interface ExpiringValue<T>
        Returns:
        true if the value has expired based on the current system time, false otherwise.
      • isExpired

        public boolean isExpired​(Instant now)
        Description copied from interface: ExpiringValue
        Checks if the value has already expired.
        Specified by:
        isExpired in interface ExpiringValue<T>
        Parameters:
        now - The reference point in time to check expiration against.
        Returns:
        true if the value has expired based on the given instant, false otherwise.