Class TimedData<T>

  • Type Parameters:
    T - The data value.
    All Implemented Interfaces:
    java.util.function.Supplier<T>, tech.uom.lib.common.function.Nameable

    public class TimedData<T>
    extends java.lang.Object
    implements tech.uom.lib.common.function.Nameable, java.util.function.Supplier<T>
    TimedData is a container for a data value that keeps track of its age. This class keeps track of the birth time of a bit of data, i.e. time the object is instantiated.
    The TimedData MUST be immutable.
    Version:
    0.5
    See Also:
    Wikipedia: Time Series
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.time.Instant instant  
      private java.lang.String name  
      private long timestamp  
      private T value  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TimedData​(T value, long time)
      Construct an instance of TimedData with a value and timestamp.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      T get()  
      java.time.Instant getInstant()  
      java.lang.String getName()  
      long getTimestamp()
      Returns the time with which this TimedData was created.
      int hashCode()  
      static <T> TimedData<T> of​(T val, long time)
      Returns an MeasurementRange with the specified values.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • value

        private final T value
      • timestamp

        private final long timestamp
      • instant

        private final java.time.Instant instant
      • name

        private java.lang.String name
    • Constructor Detail

      • TimedData

        protected TimedData​(T value,
                            long time)
        Construct an instance of TimedData with a value and timestamp.
        Parameters:
        data - The value of the TimedData.
        time - The timestamp of the TimedData.
    • Method Detail

      • of

        public static <T> TimedData<T> of​(T val,
                                          long time)
        Returns an MeasurementRange with the specified values.
        Type Parameters:
        T - the class of the value
        Parameters:
        val - The minimum value for the measurement range.
        time - The maximum value for the measurement range.
        Returns:
        an MeasurementRange with the given values
      • getTimestamp

        public long getTimestamp()
        Returns the time with which this TimedData was created.
        Returns:
        the time of creation
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface tech.uom.lib.common.function.Nameable
      • get

        public T get()
        Specified by:
        get in interface java.util.function.Supplier<T>
      • equals

        public boolean equals​(java.lang.Object obj)
        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
      • getInstant

        public java.time.Instant getInstant()