de.unkrig.commons.util.time
Class TimeInterval

java.lang.Object
  extended by de.unkrig.commons.util.time.TimeInterval

public final class TimeInterval
extends java.lang.Object

A time interval has an optional beginning, an optional duration and an optional ending.

An 'undefined time interval' has neither a beginning, duration nor ending.

A 'defined time interval' has a beginning, a duration and an ending, which are consistent with each other, i.e. beginning + duration = ending.

A 'half-defined' time interval has


Constructor Summary
TimeInterval()
          Constructs an uninitialized TimeInterval.
TimeInterval(TimeInterval other)
           
 
Method Summary
 PointOfTime getBeginning()
          The beginning of this time interval
 Duration getDuration()
          The duration of this time interval
 PointOfTime getEnding()
          The ending of this time interval
 TimeInterval setBeginning(PointOfTime beginning)
          Changes the beginning of this interval.
 TimeInterval setDuration(Duration duration)
          Changes the duration of this interval.
 TimeInterval setEnding(PointOfTime ending)
          Changes the ending of this interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeInterval

public TimeInterval(TimeInterval other)

TimeInterval

public TimeInterval()
Constructs an uninitialized TimeInterval.

Method Detail

setBeginning

public TimeInterval setBeginning(@Nullable
                                 PointOfTime beginning)
Changes the beginning of this interval.

Returns:
This object
Throws:
java.lang.IllegalStateException - The beginning is inconsistent with this object's duration and ending, i.e. all three are non-null, and beginning + duration != ending

setDuration

public TimeInterval setDuration(@Nullable
                                Duration duration)
Changes the duration of this interval.

Returns:
This object
Throws:
java.lang.IllegalStateException - The duration is inconsistent with this object's beginning and ending, i.e. all three are non-null, and beginning + duration != ending

setEnding

public TimeInterval setEnding(@Nullable
                              PointOfTime ending)
Changes the ending of this interval.

Returns:
This object
Throws:
java.lang.IllegalStateException - The ending is inconsistent with this object's beginning and duration, i.e. all three are non-null, and beginning + duration != ending

getBeginning

@Nullable
public PointOfTime getBeginning()
The beginning of this time interval


getDuration

@Nullable
public Duration getDuration()
The duration of this time interval


getEnding

@Nullable
public PointOfTime getEnding()
The ending of this time interval