Class EInterval
- java.lang.Object
 - 
- net.sf.eBus.messages.EMessageObject
 - 
- net.sf.eBus.messages.EField
 - 
- net.sf.eBusx.time.EInterval
 
 
 
 
- 
- All Implemented Interfaces:
 java.io.Serializable
public final class EInterval extends EField
Implements a time interval from oneInstantto another.EIntervalguarantees that begin time is ≤ end time. Each end point may be separately configured to be inclusive or exclusive. If begin time equals end time then both ends must be marked as inclusive.EIntervalextendsEFieldso that it can be used in an eBus message. This means thatEInterval.Buildermust be used to create anEIntervalinstance.EIntervalis immutable and thread-safe.Allen's Interval Algebra
Allen's temporal reasoning calculus is based on 13 base relations. Since 12 of these relations are simply inverses of each other (for example the inverse of x precedes y is y is preceded by x) only 7 relations are implemented in
EIntervalwhich are:- 
     
:
     interval 1 precedes interval 2 if interval 1 end time <
     interval 2 begin time.
    - 
    
: interval 1
    meets interval 2 if if interval 1 end time equals interval
    2 begin time.
    - 
     
:
     interval 1 overlaps interval 2 if interval 1 begin time
     < interval 2 begin time and interval 1 end time <
     interval 2 end time.
    - 
     
:
     interval 1 contains interval 2 if interval 1 begin time
     < interval 2 begin time and interval 1 end time >
     interval 2 end time.
    - 
     
: interval 1
     starts interval 2 if interval 1 begin time equals interval
     2 begin time and interval 1 end time < interval 2 end
     time.
    - 
     
:
     interval 1 finishes interval 2 if interval 1 begin time
     > interval 2 begin time and interval 1 end time equals
     interval 2 end time.
    - 
     
: interval 1
     begin and end times equal interval 2 begin and end times.
    
Note: interval algebra methods below are based solely on the end point times and do not take clusivity into account.
- Author:
 - Charles W. Rapp
 - See Also:
 - Serialized Form
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEInterval.BuilderEIntervalinstances may be created only by using aBuilderinstance.static classEInterval.ClusivitySpecifies whether an end point is inclusive or exclusive.static classEInterval.TimeLocationDenotes if a timestamp denotes the past, current time, future, or future on-going. 
- 
Field Summary
Fields Modifier and Type Field Description EInterval.ClusivitybeginClusivityInterval begin time clusivity.EInterval.TimeLocationbeginLocationInterval begins at this time location.java.time.InstantbeginTimeInterval begin time.EInterval.ClusivityendClusivityInterval end time clusivity.EInterval.TimeLocationendLocationInterval ends at this time location.java.time.InstantendTimeInterval end time. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EInterval.Builderbuilder()Returns a newEIntervalbuilder instance which is used to create anEIntervalobject.booleancontains(EInterval interval)
:
 Returns trueif:this EIntervalbegin time <intervalbegin time andthis EIntervalend time >intervalend time.booleanequals(java.lang.Object o)
:
 Returns trueif:ois the sameEIntervalinstance asthisinterval orois a non-null EIntervalinstance with the same end points and clusivities asthis EIntervalinstance.booleanfinishes(EInterval interval)
:
 Returns trueif this interval starts afterintervaLbuts ends at the same time.inthashCode()Returns hash code based on end point times and clusivities.booleanmeets(EInterval interval)
:
 Returns trueifthis EIntervalend time equalsintervalbegin time.booleanoverlaps(EInterval interval)
:
 Returns trueif:this EIntervalend time is >interval's begin time,this EIntervalend time is <interval's end time, andthis EIntervalbegin time is <interval's begin time.booleanprecedes(EInterval interval)
:
 Returns trueifthis EIntervalend time is <intervalbegin time.booleanstarts(EInterval interval)
:
 Returns trueif this interval starts at the same time asintervalbut ends before.java.lang.StringtoString()Returns textual representation of end point times and clusivities. 
 - 
 
- 
- 
Field Detail
- 
beginLocation
public final EInterval.TimeLocation beginLocation
Interval begins at this time location. This is needed when for relative times likeEInterval.TimeLocation.NOWandEInterval.TimeLocation.ON_GOING. 
- 
beginTime
public final java.time.Instant beginTime
Interval begin time. 
- 
beginClusivity
public final EInterval.Clusivity beginClusivity
Interval begin time clusivity. 
- 
endLocation
public final EInterval.TimeLocation endLocation
Interval ends at this time location. This is needed for relative times likeEInterval.TimeLocation.NOWandEInterval.TimeLocation.ON_GOING. 
- 
endTime
public final java.time.Instant endTime
Interval end time. 
- 
endClusivity
public final EInterval.Clusivity endClusivity
Interval end time clusivity. 
 - 
 
- 
Method Detail
- 
toString
public java.lang.String toString()
Returns textual representation of end point times and clusivities. Uses defaultInstanttime format.- Overrides:
 toStringin classjava.lang.Object- Returns:
 - interval as text.
 
 
- 
equals
public boolean equals(java.lang.Object o)
:
 Returns trueif:- 
     
ois the sameEIntervalinstance asthisinterval or - 
     
ois a non-null EIntervalinstance with the same end points and clusivities asthis EIntervalinstance. 
false.- Overrides:
 equalsin classjava.lang.Object- Parameters:
 o- comparison object.- Returns:
 trueifois a non-null EIntervalinstance whose end points are equal and have the same clusivities.
 - 
     
 
- 
hashCode
public int hashCode()
Returns hash code based on end point times and clusivities.- Overrides:
 hashCodein classjava.lang.Object- Returns:
 - hash code based on end point times and clusivities.
 
 
- 
precedes
public boolean precedes(EInterval interval)
:
 Returns trueifthis EIntervalend time is <intervalbegin time.Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueifthis EIntervalprecedesintervalandfalseotherwise.
 
- 
meets
public boolean meets(EInterval interval)
:
 Returns trueifthis EIntervalend time equalsintervalbegin time.Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueifthis EIntervalmeetsintervalandfalseotherwise.
 
- 
overlaps
public boolean overlaps(EInterval interval)
:
 Returns trueif:- 
     
this EIntervalend time is >interval's begin time, - 
     
this EIntervalend time is <interval's end time, and - 
     
this EIntervalbegin time is <interval's begin time. 
Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueifthis EIntervaloverlapsintervalandfalseotherwise.
 - 
     
 
- 
contains
public boolean contains(EInterval interval)
:
 Returns trueif:- 
     
this EIntervalbegin time <intervalbegin time and - 
     
this EIntervalend time >intervalend time. 
Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueif this interval begins beforeintervaland ends after.
 - 
     
 
- 
starts
public boolean starts(EInterval interval)
:
 Returns trueif this interval starts at the same time asintervalbut ends before. That is:- 
     
this EIntervalbegin time equalsintervalbegin time and - 
     
this EIntervalend time <intervalend time. 
Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueif this interval starts at the same time asintervalbut ends before.
 - 
     
 
- 
finishes
public boolean finishes(EInterval interval)
:
 Returns trueif this interval starts afterintervaLbuts ends at the same time. That is:- 
     
this EIntervalbegin time >intervalbegin time and - 
     
this EIntervalend time equalsintervalend time. 
Note that this comparison is based only on time and does not take clusivity into account.
- Parameters:
 interval- comparison time interval.- Returns:
 trueif this interval starts afterintervaLbuts ends at the same time.
 - 
     
 
- 
builder
public static EInterval.Builder builder()
Returns a newEIntervalbuilder instance which is used to create anEIntervalobject. It is recommended that a new builder be used when creating anEIntervalinstance and not re-use a previously createdBuilderto create multiple intervals.- Returns:
 - interval builder instance.
 
 
 - 
 
 -