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 TypeMethodDescriptionbooleancontains(long time) Decides if a time is strictly contained by the period.static booleancontains(ITimePeriod period, long time) Decides if a time is contained by the period.booleanfrom(long from) Sets the 'from' boundary.Sets the raw 'from' boundary.longGets the resolved current time.getFrom()Gets the raw 'from' boundary.longGets the resolved 'from' timestamp.getTo()Gets the raw 'to' boundary.longGets the resolved 'to' timestamp.booleanGets if the period has a start boundary.inthashCode()booleanGets if the period has an end boundary.booleanGets if the 'from' boundary is made of the server current time.booleanisToNow()Gets if the 'to' boundary is made of the server current time.voidresolve(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
-
NOW
Keyword to represent the server current time.- See Also:
-
-
Constructor Details
-
TimePeriodDto
public TimePeriodDto()Default constructor. -
TimePeriodDto
Full constructor.- Parameters:
from- from boundaryto- to boundary
-
TimePeriodDto
Copy constructor.- Parameters:
period- period to copy
-
-
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:ITimePeriodResolves the current time for boundaries.- Specified by:
resolvein interfaceITimePeriod- Parameters:
clock- the time supplier with respect to which the time period need be resolved
-
hasFromTime
public boolean hasFromTime()Description copied from interface:ITimePeriodGets if the period has a start boundary.- Specified by:
hasFromTimein interfaceITimePeriod- Returns:
- true if a 'from' value is defined
-
getFromTime
public long getFromTime()Description copied from interface:ITimePeriodGets the resolved 'from' timestamp.- Specified by:
getFromTimein interfaceITimePeriod- Returns:
- boundary as a UNIX timestamp in ms
-
isFromNow
public boolean isFromNow()Description copied from interface:ITimePeriodGets if the 'from' boundary is made of the server current time.- Specified by:
isFromNowin interfaceITimePeriod- Returns:
- true if the boundary is dynamic, false otherwise
-
hasToTime
public boolean hasToTime()Description copied from interface:ITimePeriodGets if the period has an end boundary.- Specified by:
hasToTimein interfaceITimePeriod- Returns:
- true if a 'to' value is defined
-
getToTime
public long getToTime()Description copied from interface:ITimePeriodGets the resolved 'to' timestamp.- Specified by:
getToTimein interfaceITimePeriod- Returns:
- boundary as a UNIX timestamp in ms
-
isToNow
public boolean isToNow()Description copied from interface:ITimePeriodGets if the 'to' boundary is made of the server current time.- Specified by:
isToNowin interfaceITimePeriod- Returns:
- true if the boundary is dynamic, false otherwise
-
getCurrentTime
public long getCurrentTime()Description copied from interface:ITimePeriodGets the resolved current time.- Specified by:
getCurrentTimein interfaceITimePeriod- Returns:
- the current time.
-
contains
public boolean contains(long time) Description copied from interface:ITimePeriodDecides if a time is strictly contained by the period.- Specified by:
containsin 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()
-