Package be.gaudry.model.edu
Class Period
java.lang.Object
be.gaudry.model.AbstractLightObject
be.gaudry.model.edu.Period
- All Implemented Interfaces:
IPeriod
,ILightObject
,Serializable
- Direct Known Subclasses:
SchoolYear
- Since:
- 1.0 Oct 12, 2008
- Author:
- Steph GAUDRY
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from interface be.gaudry.model.ILightObject
DEFAULT_ID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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:boolean
containsEndInclude(Date date)
Check if a given date is between the period start (excluded) and the period end (included).boolean
containsStartInclude(Date date)
Check if a given date is between the period start (included) and the period end (excluded).Returns a formated String with the interval between the start date and end date; or a custom display if thesetDisplay(String)
has been called.The date when theIPeriod
stops.int
getId()
Identifier of the ILightObjectThe date when theIPeriod
starts.void
setDisplay(String display)
Sets the display.void
setEndDate(Date endDate)
void
setId(int id)
void
setParentPeriod(Period parentPeriod)
void
setStartDate(Date startDate)
toString()
Builds a string with variables values and the class.Methods inherited from class be.gaudry.model.AbstractLightObject
equals, hashCode
-
Field Details
-
defaultPeriod
-
-
Constructor Details
-
Period
public Period() -
Period
- Parameters:
id
-display
-
-
Period
- Parameters:
startDate
-endDate
-
-
-
Method Details
-
contains
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
Check if a given date is between the period start (excluded) and the period end (included).- Parameters:
date
- date to check- Returns:
-
containsStartInclude
Check if a given date is between the period start (included) and the period end (excluded).- Parameters:
date
- date to check- Returns:
-
getStartDate
Description copied from interface:IPeriod
The date when theIPeriod
starts.- Specified by:
getStartDate
in interfaceIPeriod
- Returns:
- the startDate
-
setStartDate
- Specified by:
setStartDate
in interfaceIPeriod
- Parameters:
startDate
- the startDate to set- See Also:
IPeriod.getStartDate()
-
getEndDate
Description copied from interface:IPeriod
The date when theIPeriod
stops.- Specified by:
getEndDate
in interfaceIPeriod
- Returns:
- the endDate
-
setEndDate
- Specified by:
setEndDate
in interfaceIPeriod
- Parameters:
endDate
- the endDate to set- See Also:
IPeriod.getEndDate()
-
getParentPeriod
- Returns:
- the parentPeriod
-
setParentPeriod
- Parameters:
parentPeriod
- the parentPeriod to set
-
toString
Description copied from class:AbstractLightObject
Builds a string with variables values and the class.- Overrides:
toString
in classAbstractLightObject
- Returns:
- a String representation of this LightObject only for debugging
- See Also:
getIntervalString()
-
getIntervalString
- Specified by:
getIntervalString
in interfaceIPeriod
- Returns:
- the
IPeriod
String representation
-
getId
public int getId()Description copied from interface:ILightObject
Identifier of the ILightObject- Specified by:
getId
in interfaceILightObject
- Returns:
- the id
-
setId
public void setId(int id)- Specified by:
setId
in interfaceILightObject
- Parameters:
id
- the id to set- See Also:
ILightObject.getId()
-
getDisplay
Returns a formated String with the interval between the start date and end date; or a custom display if thesetDisplay(String)
has been called.- Specified by:
getDisplay
in interfaceILightObject
- Returns:
- the display
- See Also:
ILightObject.getDisplay()
-
setDisplay
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 theILightObject.getDisplay()
method will return the same string as the display argument. \nIn many subclasses of the basic implementationAbstractLightObject
, theILightObject.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 interfaceILightObject
- Parameters:
display
- String representation of the object- See Also:
ILightObject.setDisplay(java.lang.String)
-