Class Interval

  • All Implemented Interfaces:
    java.lang.Comparable<Interval>

    public class Interval
    extends java.lang.Object
    implements java.lang.Comparable<Interval>
    Interval abstraction (2 dates)
    Author:
    ludovic
    • Field Detail

      • startDate

        protected java.util.Date startDate
      • endDate

        protected java.util.Date endDate
      • linkedElement

        protected java.lang.Object linkedElement
    • Constructor Detail

      • Interval

        public Interval​(java.util.Date startDate,
                        java.util.Date endDate,
                        java.lang.Object linkedElement)
      • Interval

        public Interval​(Interval interval)
    • Method Detail

      • getLinkedElement

        public java.lang.Object getLinkedElement()
        Returns:
        the linkedElement
      • setLinkedElement

        public void setLinkedElement​(java.lang.Object linkedElement)
        Parameters:
        linkedElement - the linkedElement to set
      • getStartDate

        public java.util.Date getStartDate()
        Returns:
        the startDate
      • setStartDate

        public void setStartDate​(java.util.Date startDate)
        Parameters:
        startDate - the startDate to set
      • getEndDate

        public java.util.Date getEndDate()
        Returns:
        the endDate
      • setEndDate

        public void setEndDate​(java.util.Date endDate)
        Parameters:
        endDate - the endDate to set
      • 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 java.lang.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 java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object