Package com.qfs.snl.impl
Class TimePeriod
java.lang.Object
com.qfs.snl.impl.TimePeriod
- All Implemented Interfaces:
ITimePeriod
Effective implementation of ITimePeriod.
- Author:
- ActiveViam
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with prescribed time supplier.TimePeriod(ITimePeriod period) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(long time) Decides if a time is strictly contained by the period.booleanfrom(long time) Adds a start boundary.fromNow()Adds a start boundary using server current time.longGets the resolved current time.longGets the resolved 'from' timestamp.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 time) Adds an end boundary to the time period.toNow()Adds an end boundary to the period using server current time.toString()Methods inherited from interface com.qfs.snl.ITimePeriod
equals, hashCode
-
Constructor Details
-
TimePeriod
public TimePeriod()Default constructor with prescribed time supplier.This creates a time period without boundaries.
-
TimePeriod
Copy constructor.- Parameters:
period- period to copy
-
-
Method Details
-
from
Adds a start boundary.- Parameters:
time- timestamp in ms- Returns:
- this
-
fromNow
Adds a start boundary using server current time.- Returns:
- this
-
to
Adds an end boundary to the time period.- Parameters:
time- timestamp in ms- Returns:
- this
-
toNow
Adds an end boundary to the period using server current time.- 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.
-
toString
-
equals
-
hashCode
public int hashCode()
-