Package com.qfs.snl.dtos
Class TimePeriodDto
java.lang.Object
com.qfs.snl.dtos.TimePeriodDto
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TimePeriodDto
(ITimePeriod period) Copy constructor.TimePeriodDto
(String from, String to) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(long time) Decides if a time is strictly contained by the period.static boolean
contains
(ITimePeriod period, long time) Decides if a time is contained by the period.boolean
from
(long from) Sets the 'from' boundary.Sets the raw 'from' boundary.long
Gets the resolved current time.getFrom()
Gets the raw 'from' boundary.long
Gets the resolved 'from' timestamp.getTo()
Gets the raw 'to' boundary.long
Gets the resolved 'to' timestamp.boolean
Gets if the period has a start boundary.int
hashCode()
boolean
Gets if the period has an end boundary.boolean
Gets if the 'from' boundary is made of the server current time.boolean
isToNow()
Gets if the 'to' boundary is made of the server current time.void
resolve
(ITimeSupplier clock) Resolves the current time for boundaries.to
(long to) Sets the 'to' boundary.Sets the raw 'to' boundary.toString()
Methods inherited from interface com.qfs.snl.ITimePeriod
equals, hashCode
-
Field Details
-
Constructor Details
-
Method Details
-
getFrom
Gets the raw 'from' boundary.- Returns:
- the boundary
-
from
Sets the raw 'from' boundary.- Parameters:
from
- boundary- Returns:
- this
-
from
Sets the 'from' boundary.- Parameters:
from
- boundary in ms- Returns:
- this
-
getTo
Gets the raw 'to' boundary.- Returns:
- the boundary
-
to
Sets the raw 'to' boundary.- Parameters:
to
- boundary- Returns:
- this
-
to
Sets the 'to' boundary.- Parameters:
to
- boundary in ms- Returns:
- this
-
resolve
Description copied from interface:ITimePeriod
Resolves the current time for boundaries.- Specified by:
resolve
in interfaceITimePeriod
- Parameters:
clock
- the time supplier with respect to which the time period need be resolved
-
hasFromTime
public boolean hasFromTime()Description copied from interface:ITimePeriod
Gets if the period has a start boundary.- Specified by:
hasFromTime
in interfaceITimePeriod
- Returns:
- true if a 'from' value is defined
-
getFromTime
public long getFromTime()Description copied from interface:ITimePeriod
Gets the resolved 'from' timestamp.- Specified by:
getFromTime
in interfaceITimePeriod
- Returns:
- boundary as a UNIX timestamp in ms
-
isFromNow
public boolean isFromNow()Description copied from interface:ITimePeriod
Gets if the 'from' boundary is made of the server current time.- Specified by:
isFromNow
in interfaceITimePeriod
- Returns:
- true if the boundary is dynamic, false otherwise
-
hasToTime
public boolean hasToTime()Description copied from interface:ITimePeriod
Gets if the period has an end boundary.- Specified by:
hasToTime
in interfaceITimePeriod
- Returns:
- true if a 'to' value is defined
-
getToTime
public long getToTime()Description copied from interface:ITimePeriod
Gets the resolved 'to' timestamp.- Specified by:
getToTime
in interfaceITimePeriod
- Returns:
- boundary as a UNIX timestamp in ms
-
isToNow
public boolean isToNow()Description copied from interface:ITimePeriod
Gets if the 'to' boundary is made of the server current time.- Specified by:
isToNow
in interfaceITimePeriod
- Returns:
- true if the boundary is dynamic, false otherwise
-
getCurrentTime
public long getCurrentTime()Description copied from interface:ITimePeriod
Gets the resolved current time.- Specified by:
getCurrentTime
in interfaceITimePeriod
- Returns:
- the current time.
-
contains
public boolean contains(long time) Description copied from interface:ITimePeriod
Decides if a time is strictly contained by the period.- Specified by:
contains
in interfaceITimePeriod
- Parameters:
time
- timestamp in ms- Returns:
- true if the period contains the time.
-
contains
Decides if a time is contained by the period.The upper boundary is strict, the lower boundary is included
- Parameters:
period
- period to considertime
- timestamp in ms- Returns:
- true if the period contains the time.
-
toString
-
equals
-
hashCode
public int hashCode()
-