Class EInterval.Builder
- java.lang.Object
-
- net.sf.eBus.messages.EMessageObject.Builder<M>
-
- net.sf.eBus.messages.EField.Builder<EInterval>
-
- net.sf.eBusx.time.EInterval.Builder
-
- Enclosing class:
- EInterval
public static final class EInterval.Builder extends EField.Builder<EInterval>
EInterval
instances may be created only by using aBuilder
instance. ABuilder
instance is obtained by callingEInterval.builder()
which returns a newly instantiatedBuilder
instance. It is recommended that a newBuilder
instance be used to create an interval rather than re-using a builder instance to create multiple intervals.
-
-
Field Summary
-
Fields inherited from class net.sf.eBus.messages.EMessageObject.Builder
mTargetClass
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EInterval.Builder
beginClusivity(EInterval.Clusivity clusivity)
Sets interval begin time clusivity.EInterval.Builder
beginLocation(EInterval.TimeLocation location)
Sets interval begin location.EInterval.Builder
beginNow(EInterval.Clusivity clusivity)
Sets interval begin time to current time and begin time location toEInterval.TimeLocation.NOW
but the clusivity to the given value.EInterval.Builder
beginTime(java.time.Instant beginTime)
Sets interval begin time.EInterval.Builder
beginTime(java.time.Instant beginTime, EInterval.Clusivity clusivity)
Sets interval begin time and clusivity.protected EInterval
buildImpl()
Returns a new interval instance based on this builder's settings.EInterval.Builder
endClusivity(EInterval.Clusivity clusivity)
Sets interval end time clusivity.EInterval.Builder
endLocation(EInterval.TimeLocation location)
Sets interval end location.EInterval.Builder
endNever()
Sets interval end time toInstant.MAX
and end time location toEInterval.TimeLocation.ON_GOING
.EInterval.Builder
endNow(EInterval.Clusivity clusivity)
Sets interval end time to current time and end time location toEInterval.TimeLocation.NOW
.EInterval.Builder
endTime(java.time.Instant endTime)
Sets the interval end time.EInterval.Builder
endTime(java.time.Instant endTime, EInterval.Clusivity clusivity)
Sets interval end time and clusivity.EInterval.Builder
nowOnly()
Sets interval for current time only, inclusive.protected Validator
validate(Validator problems)
Checks if: the begin and end times and clusivity are set and begin time is either < or ≤ end time depending on clusivity settings.-
Methods inherited from class net.sf.eBus.messages.EMessageObject.Builder
build
-
-
-
-
Method Detail
-
validate
protected Validator validate(Validator problems)
Checks if:- the begin and end times and clusivity are set and
- begin time is either < or ≤ end time depending on clusivity settings.
- if begin time equals end time then both times must be inclusive.
- Overrides:
validate
in classEField.Builder<EInterval>
- Parameters:
problems
- add each detected problem to this validator.- Returns:
problems
.- See Also:
Validator
-
buildImpl
protected EInterval buildImpl()
Returns a new interval instance based on this builder's settings.- Specified by:
buildImpl
in classEMessageObject.Builder<EInterval>
- Returns:
- new interval instance.
-
beginTime
public EInterval.Builder beginTime(java.time.Instant beginTime, EInterval.Clusivity clusivity)
Sets interval begin time and clusivity. Begin time location is based on whetherbeginTime
is < or ≥ to current time. Returnsthis Builder
instance so that builder method calls can be chained.- Parameters:
beginTime
- interval begin time.clusivity
- interval begin time clusivity.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- if eitherbeginTime
orclusivity
isnull
. Note: if this is the case, then neither begin time nor clusivity is set.- See Also:
beginNow(Clusivity)
-
beginNow
public EInterval.Builder beginNow(EInterval.Clusivity clusivity)
Sets interval begin time to current time and begin time location toEInterval.TimeLocation.NOW
but the clusivity to the given value. When combined with clusivity defines whether interval begins at or just after now. Returnsthis Builder
instance so that builder method calls can be chained.- Parameters:
clusivity
- interval begin time clusivity.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifclusivity
isnull
. If this is the case, then begin time and location are not set.- See Also:
beginTime(Instant, Clusivity)
-
endTime
public EInterval.Builder endTime(java.time.Instant endTime, EInterval.Clusivity clusivity)
Sets interval end time and clusivity. End time location is based on whetherendTime
is < or ≥ to current time. Returnsthis Builder
instance so that builder method calls can be chained.- Parameters:
endTime
- interval end time.clusivity
- interval end time clusivity.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- if eitherendTime
orclusivity
isnull
. Note: if this is the case, then neither end time nor clusivity is set.
-
endNow
public EInterval.Builder endNow(EInterval.Clusivity clusivity)
Sets interval end time to current time and end time location toEInterval.TimeLocation.NOW
. When combined with clusivity defines whether interval end at or just before now. Returnsthis Builder
instance so that builder method calls can be chained.- Parameters:
clusivity
- interval end time clusivity.- Returns:
this Builder
instance.
-
endNever
public EInterval.Builder endNever()
Sets interval end time toInstant.MAX
and end time location toEInterval.TimeLocation.ON_GOING
. Clusivity is set toexclusive
but is irrelevant since the end time is never reached. Returnsthis Builder
instance so that builder method calls can be chained.- Returns:
this Builder
instance.
-
nowOnly
public EInterval.Builder nowOnly()
Sets interval for current time only, inclusive. Both begin and end times are set to now, clusivity set to inclusive, and time location to now. Returnsthis Builder
instance so that builder method calls can be chained.- Returns:
this Builder
instance.
-
beginLocation
public EInterval.Builder beginLocation(EInterval.TimeLocation location)
Sets interval begin location. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please usebeginTime(Instant, Clusivity)
orbeginNow(Clusivity)
instead.- Parameters:
location
- begin time location.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- iflocation
isnull
.- See Also:
beginTime(Instant, Clusivity)
,beginNow(Clusivity)
-
beginTime
public EInterval.Builder beginTime(java.time.Instant beginTime)
Sets interval begin time. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please usebeginTime(Instant, Clusivity)
orbeginNow(Clusivity)
instead.- Parameters:
beginTime
- interval begin time.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifbeginTime
isnull
.- See Also:
beginTime(Instant, Clusivity)
,beginNow(Clusivity)
-
beginClusivity
public EInterval.Builder beginClusivity(EInterval.Clusivity clusivity)
Sets interval begin time clusivity. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please usebeginTime(Instant, Clusivity)
orbeginNow(Clusivity)
instead.- Parameters:
clusivity
- interval begin time clusivity.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifclusivity
isnull
.- See Also:
beginTime(Instant, Clusivity)
,beginNow(Clusivity)
-
endLocation
public EInterval.Builder endLocation(EInterval.TimeLocation location)
Sets interval end location. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please useendTime(Instant, Clusivity)
,endNow(Clusivity)
, orendNever()
instead.- Parameters:
location
- end time location.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifendTime
isnull
.- See Also:
endTime(Instant, Clusivity)
,endNow(Clusivity)
,endNever()
-
endTime
public EInterval.Builder endTime(java.time.Instant endTime)
Sets the interval end time. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please useendTime(Instant, Clusivity)
,endNow(Clusivity)
, orendNever()
instead.- Parameters:
endTime
- interval end time.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifendTime
isnull
.- See Also:
endTime(Instant, Clusivity)
,endNow(Clusivity)
,endNever()
-
endClusivity
public EInterval.Builder endClusivity(EInterval.Clusivity clusivity)
Sets interval end time clusivity. Returnsthis Builder
instance so that builder method calls can be chained.This method is required for
EInterval
de-serialization and should not be used for application purposes. Please useendTime(Instant, Clusivity)
,endNow(Clusivity)
, orendNever()
instead.- Parameters:
clusivity
- interval begin time clusivity.- Returns:
this Builder
instance.- Throws:
java.lang.NullPointerException
- ifclusivity
isnull
.- See Also:
endTime(Instant, Clusivity)
,endNow(Clusivity)
,endNever()
-
-