Class TimePeriodDto

java.lang.Object
com.qfs.snl.dtos.TimePeriodDto
All Implemented Interfaces:
ITimePeriod

public class TimePeriodDto extends Object implements ITimePeriod
DTO representing a time period.

This uses String to represent the boundaries, so either one can use the keyword NOW or a long value stored in a string.

Author:
ActiveViam
  • Field Details Link icon

  • Constructor Details Link icon

    • TimePeriodDto Link icon

      public TimePeriodDto()
      Default constructor.
    • TimePeriodDto Link icon

      public TimePeriodDto(String from, String to)
      Full constructor.
      Parameters:
      from - from boundary
      to - to boundary
    • TimePeriodDto Link icon

      public TimePeriodDto(ITimePeriod period)
      Copy constructor.
      Parameters:
      period - period to copy
  • Method Details Link icon

    • getFrom Link icon

      public String getFrom()
      Gets the raw 'from' boundary.
      Returns:
      the boundary
    • from Link icon

      public TimePeriodDto from(String from)
      Sets the raw 'from' boundary.
      Parameters:
      from - boundary
      Returns:
      this
    • from Link icon

      public TimePeriodDto from(long from)
      Sets the 'from' boundary.
      Parameters:
      from - boundary in ms
      Returns:
      this
    • getTo Link icon

      public String getTo()
      Gets the raw 'to' boundary.
      Returns:
      the boundary
    • to Link icon

      public TimePeriodDto to(String to)
      Sets the raw 'to' boundary.
      Parameters:
      to - boundary
      Returns:
      this
    • to Link icon

      public TimePeriodDto to(long to)
      Sets the 'to' boundary.
      Parameters:
      to - boundary in ms
      Returns:
      this
    • resolve Link icon

      public void resolve(ITimeSupplier clock)
      Description copied from interface: ITimePeriod
      Resolves the current time for boundaries.
      Specified by:
      resolve in interface ITimePeriod
      Parameters:
      clock - the time supplier with respect to which the time period need be resolved
    • hasFromTime Link icon

      public boolean hasFromTime()
      Description copied from interface: ITimePeriod
      Gets if the period has a start boundary.
      Specified by:
      hasFromTime in interface ITimePeriod
      Returns:
      true if a 'from' value is defined
    • getFromTime Link icon

      public long getFromTime()
      Description copied from interface: ITimePeriod
      Gets the resolved 'from' timestamp.
      Specified by:
      getFromTime in interface ITimePeriod
      Returns:
      boundary as a UNIX timestamp in ms
    • isFromNow Link icon

      public boolean isFromNow()
      Description copied from interface: ITimePeriod
      Gets if the 'from' boundary is made of the server current time.
      Specified by:
      isFromNow in interface ITimePeriod
      Returns:
      true if the boundary is dynamic, false otherwise
    • hasToTime Link icon

      public boolean hasToTime()
      Description copied from interface: ITimePeriod
      Gets if the period has an end boundary.
      Specified by:
      hasToTime in interface ITimePeriod
      Returns:
      true if a 'to' value is defined
    • getToTime Link icon

      public long getToTime()
      Description copied from interface: ITimePeriod
      Gets the resolved 'to' timestamp.
      Specified by:
      getToTime in interface ITimePeriod
      Returns:
      boundary as a UNIX timestamp in ms
    • isToNow Link icon

      public boolean isToNow()
      Description copied from interface: ITimePeriod
      Gets if the 'to' boundary is made of the server current time.
      Specified by:
      isToNow in interface ITimePeriod
      Returns:
      true if the boundary is dynamic, false otherwise
    • getCurrentTime Link icon

      public long getCurrentTime()
      Description copied from interface: ITimePeriod
      Gets the resolved current time.
      Specified by:
      getCurrentTime in interface ITimePeriod
      Returns:
      the current time.
    • contains Link icon

      public boolean contains(long time)
      Description copied from interface: ITimePeriod
      Decides if a time is strictly contained by the period.
      Specified by:
      contains in interface ITimePeriod
      Parameters:
      time - timestamp in ms
      Returns:
      true if the period contains the time.
    • contains Link icon

      public static boolean contains(ITimePeriod period, long time)
      Decides if a time is contained by the period.

      The upper boundary is strict, the lower boundary is included

      Parameters:
      period - period to consider
      time - timestamp in ms
      Returns:
      true if the period contains the time.
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object