Class Period

All Implemented Interfaces:
IPeriod, ILightObject, Serializable
Direct Known Subclasses:
SchoolYear

public class Period extends AbstractLightObject implements IPeriod
Since:
1.0 Oct 12, 2008
Author:
Steph GAUDRY
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • Period

      public Period()
    • Period

      public Period(int id, String display)
      Parameters:
      id -
      display -
    • Period

      public Period(int id, String display, Date startDate, Date endDate)
      Parameters:
      startDate -
      endDate -
  • Method Details

    • contains

      public boolean contains(Date date)
      Check if a given date is between the period start (excluded) and the period end (excluded).
      If you want to know if a date match including the start and end dates, you may do like that:
       if (date.equals(period.getStartDate()) || date.equals(period.getEndDate())) {
        return true;
       }else{
        return period.contains(date);
       }
      Parameters:
      date - date to check
      Returns:
      true if the given date is included into this Period
    • containsEndInclude

      public boolean containsEndInclude(Date date)
      Check if a given date is between the period start (excluded) and the period end (included).
      Parameters:
      date - date to check
      Returns:
    • containsStartInclude

      public boolean containsStartInclude(Date date)
      Check if a given date is between the period start (included) and the period end (excluded).
      Parameters:
      date - date to check
      Returns:
    • getStartDate

      public Date getStartDate()
      Description copied from interface: IPeriod
      The date when the IPeriod starts.
      Specified by:
      getStartDate in interface IPeriod
      Returns:
      the startDate
    • setStartDate

      public void setStartDate(Date startDate)
      Specified by:
      setStartDate in interface IPeriod
      Parameters:
      startDate - the startDate to set
      See Also:
      IPeriod.getStartDate()
    • getEndDate

      public Date getEndDate()
      Description copied from interface: IPeriod
      The date when the IPeriod stops.
      Specified by:
      getEndDate in interface IPeriod
      Returns:
      the endDate
    • setEndDate

      public void setEndDate(Date endDate)
      Specified by:
      setEndDate in interface IPeriod
      Parameters:
      endDate - the endDate to set
      See Also:
      IPeriod.getEndDate()
    • getParentPeriod

      public Period getParentPeriod()
      Returns:
      the parentPeriod
    • setParentPeriod

      public void setParentPeriod(Period parentPeriod)
      Parameters:
      parentPeriod - the parentPeriod to set
    • toString

      public String toString()
      Description copied from class: AbstractLightObject
      Builds a string with variables values and the class.
      Overrides:
      toString in class AbstractLightObject
      Returns:
      a String representation of this LightObject only for debugging
      See Also:
      getIntervalString()
    • getIntervalString

      public String getIntervalString()
      Specified by:
      getIntervalString in interface IPeriod
      Returns:
      the IPeriod String representation
    • getId

      public int getId()
      Description copied from interface: ILightObject
      Identifier of the ILightObject
      Specified by:
      getId in interface ILightObject
      Returns:
      the id
    • setId

      public void setId(int id)
      Specified by:
      setId in interface ILightObject
      Parameters:
      id - the id to set
      See Also:
      ILightObject.getId()
    • getDisplay

      public String getDisplay()
      Returns a formated String with the interval between the start date and end date; or a custom display if the setDisplay(String) has been called.
      Specified by:
      getDisplay in interface ILightObject
      Returns:
      the display
      See Also:
      ILightObject.getDisplay()
    • setDisplay

      public void setDisplay(String display)
      Sets the display. This means that the default view is no longer the interval between the start date and end date, but the display parameter. \nSets the display. \nThis general contract does not guarantee that the ILightObject.getDisplay() method will return the same string as the display argument. \nIn many subclasses of the basic implementation AbstractLightObject, the ILightObject.getDisplay() method returns a String built from a few meaningful properties. Thus, setting the display must be implemented in a way to respect the inheritance principle; the subclass behavior must be the same as expected from the supertype. \nBe careful than overriding this may produces side effects because setting the display may affects other properties. \nA good way is overriding the GenericLightObjectTest<T> class to test this. \n\nMaven dependency for the the GenericLightObjectTest<T>:
      • groupId: be.gaudry.broldev
      • artifactId: broldev.core.jpa-tests
      Specified by:
      setDisplay in interface ILightObject
      Parameters:
      display - String representation of the object
      See Also:
      ILightObject.setDisplay(java.lang.String)