com.jalios.util
Class Interval

java.lang.Object
  extended by com.jalios.util.Interval
All Implemented Interfaces:
Comparable<Interval>

public class Interval
extends Object
implements Comparable<Interval>

Interval abstraction (2 dates)

Author:
ludovic

Field Summary
protected  Date endDate
           
protected  Object linkedElement
           
protected  Date startDate
           
 
Constructor Summary
Interval(Date startDate, Date endDate, Object linkedElement)
           
Interval(Interval interval)
           
 
Method Summary
 int compareTo(Interval interval)
           
 boolean equals(Object obj)
           
 Date getEndDate()
           
 Object getLinkedElement()
           
 Date getStartDate()
           
 int hashCode()
           
 void merge(Interval interval)
          merge two interval which overlaps in one
 boolean overlapWith(Interval other)
          Indicates if the two interval overlaps or not (greedy overlap @see DateUtil.overlapWith(Date, Date, Date, Date, boolean)
 boolean overlapWith(Interval other, boolean greedy)
          Indicates if the two interval overlaps or not (greedy overlap @see DateUtil.overlapWith(Date, Date, Date, Date, boolean)
 void setEndDate(Date endDate)
           
 void setLinkedElement(Object linkedElement)
           
 void setStartDate(Date startDate)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

startDate

protected Date startDate

endDate

protected Date endDate

linkedElement

protected Object linkedElement
Constructor Detail

Interval

public Interval(Date startDate,
                Date endDate,
                Object linkedElement)

Interval

public Interval(Interval interval)
Method Detail

getLinkedElement

public Object getLinkedElement()
Returns:
the linkedElement

setLinkedElement

public void setLinkedElement(Object linkedElement)
Parameters:
linkedElement - the linkedElement to set

getStartDate

public Date getStartDate()
Returns:
the startDate

setStartDate

public void setStartDate(Date startDate)
Parameters:
startDate - the startDate to set

getEndDate

public Date getEndDate()
Returns:
the endDate

setEndDate

public void setEndDate(Date endDate)
Parameters:
endDate - the endDate to set

overlapWith

public boolean overlapWith(Interval other)
Indicates if the two interval overlaps or not (greedy overlap @see DateUtil.overlapWith(Date, Date, Date, Date, boolean)

Parameters:
other - the other Interval
Returns:
true if the interval overlaps, false otherwise

overlapWith

public boolean overlapWith(Interval other,
                           boolean greedy)
Indicates if the two interval overlaps or not (greedy overlap @see DateUtil.overlapWith(Date, Date, Date, Date, boolean)

Parameters:
other - the other Interval
greedy - indicates if the overlap is greedy or not
Returns:
true if the interval overlaps, false otherwise

compareTo

public int compareTo(Interval interval)
Specified by:
compareTo in interface Comparable<Interval>

merge

public void merge(Interval interval)
merge two interval which overlaps in one

Parameters:
interval - the interval to merge into

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2010 Jalios SA. All Rights Reserved.