Package org.goplanit.time
Class TimePeriodImpl
- java.lang.Object
-
- org.goplanit.utils.id.IdAbleImpl
-
- org.goplanit.utils.id.ExternalIdAbleImpl
-
- org.goplanit.time.TimePeriodImpl
-
- All Implemented Interfaces:
Comparable<IdAble>
,ExternalIdAble
,IdAble
,ManagedId
,TimePeriod
public class TimePeriodImpl extends ExternalIdAbleImpl implements TimePeriod
Represents a time period within the day. Used to determine the duration and start time of trips for example. We internally adopt seconds as the unit- Author:
- markr
-
-
Field Summary
-
Fields inherited from interface org.goplanit.utils.time.TimePeriod
TIMEPERIOD_ID_CLASS
-
-
Constructor Summary
Constructors Constructor Description TimePeriodImpl(TimePeriodImpl timePeriodImpl, boolean deepCopy)
Copy constructorTimePeriodImpl(IdGroupingToken groupId, long startTimeSeconds, long durationSeconds)
ConstructorTimePeriodImpl(IdGroupingToken groupId, String description, long startTimeSeconds, long durationSeconds)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TimePeriodImpl
deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call.protected static long
generateId(IdGroupingToken tokenId)
Generate id for instances of this class based on the token and class identifierString
getDescription()
Return the descriptionlong
getDurationSeconds()
Return the duration in secondslong
getStartTimeSeconds()
Return the start timelong
recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable idTimePeriodImpl
shallowClone()
Create a shallow copy of this entityString
toString()
Output this object as a String-
Methods inherited from class org.goplanit.utils.id.ExternalIdAbleImpl
getExternalId, getXmlId, setExternalId, setXmlId
-
Methods inherited from class org.goplanit.utils.id.IdAbleImpl
equals, generateAndSetId, generateId, getId, hashCode, setId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
appendExternalId, appendExternalId, getExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, getXmlId, hasExternalId, hasXmlId, setExternalId, setXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, getId, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.utils.id.ManagedId
resetChildManagedIdEntities
-
Methods inherited from interface org.goplanit.utils.time.TimePeriod
getDurationHours, getIdClass, hasDescription
-
-
-
-
Constructor Detail
-
TimePeriodImpl
public TimePeriodImpl(IdGroupingToken groupId, long startTimeSeconds, long durationSeconds)
Constructor- Parameters:
groupId
- contiguous id generation within this group for instances of this classstartTimeSeconds
- start time in seconds from midnightdurationSeconds
- duration in seconds
-
TimePeriodImpl
public TimePeriodImpl(IdGroupingToken groupId, String description, long startTimeSeconds, long durationSeconds)
Constructor- Parameters:
groupId
- contiguous id generation within this group for instances of this classdescription
- description of this time periodstartTimeSeconds
- start time of this time perioddurationSeconds
- duration of this time period
-
TimePeriodImpl
public TimePeriodImpl(TimePeriodImpl timePeriodImpl, boolean deepCopy)
Copy constructor- Parameters:
timePeriodImpl
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
generateId
protected static long generateId(IdGroupingToken tokenId)
Generate id for instances of this class based on the token and class identifier- Parameters:
tokenId
- to use- Returns:
- generated id
-
getStartTimeSeconds
public long getStartTimeSeconds()
Return the start time- Specified by:
getStartTimeSeconds
in interfaceTimePeriod
- Returns:
- start time
-
getDurationSeconds
public long getDurationSeconds()
Return the duration in seconds- Specified by:
getDurationSeconds
in interfaceTimePeriod
- Returns:
- duration
-
getDescription
public String getDescription()
Return the description- Specified by:
getDescription
in interfaceTimePeriod
- Returns:
- description of this TimePeriod
-
recreateManagedIds
public long recreateManagedIds(IdGroupingToken tokenId)
recreate the internal id(s) and set them including the Idable id- Specified by:
recreateManagedIds
in interfaceManagedId
- Parameters:
tokenId
- to use (may be null in case managed id entity does not rely on token to recreate its managed id(s))- Returns:
- the updated internal id
-
shallowClone
public TimePeriodImpl shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in interfaceTimePeriod
- Overrides:
shallowClone
in classExternalIdAbleImpl
- Returns:
- shallow copy of entity
-
deepClone
public TimePeriodImpl deepClone()
An id entity should always support a deep copy, i.e., all "owned" members will be deep copied when a clone of this instance is created via this call. To be used with caution if not called by managed id container related code- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in interfaceTimePeriod
- Overrides:
deepClone
in classExternalIdAbleImpl
- Returns:
- deep copy of entity
-
-