Class Timed<T>

  • Type Parameters:
    T - the value type

    public final class Timed<T>
    extends java.lang.Object
    Holds onto a value along with time information.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) long time  
      (package private) java.util.concurrent.TimeUnit unit  
      (package private) T value  
    • Constructor Summary

      Constructors 
      Constructor Description
      Timed​(T value, long time, @NonNull java.util.concurrent.TimeUnit unit)
      Constructs a Timed instance with the given value and time information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      int hashCode()  
      long time()
      Returns the time value.
      long time​(@NonNull java.util.concurrent.TimeUnit unit)
      Returns the contained time value in the time unit specified.
      java.lang.String toString()  
      @NonNull java.util.concurrent.TimeUnit unit()
      Returns the time unit of the contained time.
      T value()
      Returns the contained value.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • value

        final T value
      • time

        final long time
      • unit

        final java.util.concurrent.TimeUnit unit
    • Constructor Detail

      • Timed

        public Timed​(@NonNull
                     T value,
                     long time,
                     @NonNull
                     @NonNull java.util.concurrent.TimeUnit unit)
        Constructs a Timed instance with the given value and time information.
        Parameters:
        value - the value to hold
        time - the time to hold
        unit - the time unit, not null
        Throws:
        java.lang.NullPointerException - if value or unit is null
    • Method Detail

      • value

        @NonNull
        public T value()
        Returns the contained value.
        Returns:
        the contained value
      • unit

        @NonNull
        public @NonNull java.util.concurrent.TimeUnit unit()
        Returns the time unit of the contained time.
        Returns:
        the time unit of the contained time
      • time

        public long time()
        Returns the time value.
        Returns:
        the time value
      • time

        public long time​(@NonNull
                         @NonNull java.util.concurrent.TimeUnit unit)
        Returns the contained time value in the time unit specified.
        Parameters:
        unit - the time unit
        Returns:
        the converted time
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object