net.agmodel.physical
Class MutableInterval

java.lang.Object
  |
  +--net.agmodel.physical.Period
        |
        +--net.agmodel.physical.Interval
              |
              +--net.agmodel.physical.MutableInterval
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public class MutableInterval
extends Interval

A mutable version of Interval. Use where the overhead of repeatedly constructing new Intervals is unacceptable eg in tight loops.

See Also:
Serialized Form

Constructor Summary
MutableInterval()
          Creates a MutableInterval with start and end set to the beginning and end of time respecitively;
MutableInterval(Date start, Date end)
          Creates a MutableInterval from a starting and ending time.
MutableInterval(Date start, Duration duration)
          Creates a MutableInterval from a starting time and duration.
MutableInterval(Duration duration, Date end)
          Creates a MutableInterval from a duration and ending time.
 
Method Summary
 void set(Date aStart, Date anEnd)
          Sets the start and end date, ensuring that start is before end
 void set(Date start, Duration duration)
          Sets interval from an end date and duration
 void set(Duration duration, Date end)
          Sets interval from an end date and duration
 void setEnd(Date anEnd)
          Changes the end date.
 void setStart(Date aStart)
          Changes the Period start date.
 
Methods inherited from class net.agmodel.physical.Interval
clone, containsTimeQuantities, getDuration, getDuration, overlap
 
Methods inherited from class net.agmodel.physical.Period
coincidesWith, coincidesWith, coincidesWith, compareTo, encompasses, getBeginningOfTime, getEarlierOf, getEnd, getEndOfTime, getLaterOf, getStart, hasBeginning, hasEnd, toString, unionWith
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutableInterval

public MutableInterval()
Creates a MutableInterval with start and end set to the beginning and end of time respecitively;


MutableInterval

public MutableInterval(Date start,
                       Date end)
Creates a MutableInterval from a starting and ending time.

Throws:
IllegalArgumentException - if start or end are null.

MutableInterval

public MutableInterval(Duration duration,
                       Date end)
Creates a MutableInterval from a duration and ending time.

Parameters:
duration - the duration of the interval
end - the ending time of the interval
Throws:
IllegalArgumentException - if end is null

MutableInterval

public MutableInterval(Date start,
                       Duration duration)
Creates a MutableInterval from a starting time and duration.

Parameters:
start - the starting time of the interval
duration - the duration of the interval
Throws:
IllegalArgumentException - if start is null
Method Detail

setStart

public void setStart(Date aStart)
Changes the Period start date. This method is made protected rather than private to allow MutableInterval to set the start and end fields.

Overrides:
setStart in class Period
Parameters:
aStart - the new start date for the Period (cloned), which must be before the current ending date.
See Also:
set(Date,Date)

setEnd

public void setEnd(Date anEnd)
Changes the end date. This method is made protected rather than private to allow MutableInterval to set the start and end fields.

Overrides:
setEnd in class Period
Parameters:
anEnd - the new end date for the Period (cloned), which must be after the current starting date,
See Also:
set(Date,Date)

set

public void set(Date aStart,
                Date anEnd)
Sets the start and end date, ensuring that start is before end

Overrides:
set in class Period
Parameters:
aStart - the new start date for the Period (cloned)
anEnd - the new end date for the Period (cloned)

set

public void set(Duration duration,
                Date end)
Sets interval from an end date and duration

Overrides:
set in class Period
Parameters:
duration - the new duration for the Period (cloned)
end - the new end date for the Period (cloned)

set

public void set(Date start,
                Duration duration)
Sets interval from an end date and duration

Overrides:
set in class Period
Parameters:
start - the new start date for the Period (cloned)
duration - the new duration for the Period (cloned)