- java.lang.Object
-
- com.flexganttfx.model.activity.ActivityBase<T>
-
- com.flexganttfx.model.activity.MutableActivityBase<T>
-
- Type Parameters:
T
- the type of the optional user object
- All Implemented Interfaces:
Activity
,MutableActivity
- Direct Known Subclasses:
MutableCalendarActivityBase
public class MutableActivityBase<T> extends ActivityBase<T> implements MutableActivity
The base implementation of a mutable activity. An activity is considered mutable if it implements theMutableActivity
interface. By doing so we now have access to various setter methods to alter the state of the activity.- Since:
- 1.0
-
-
Field Summary
-
Fields inherited from class com.flexganttfx.model.activity.ActivityBase
DEFAULT_DURATION, endTime, id, name, startTime, userObject
-
-
Constructor Summary
Constructors Constructor Description MutableActivityBase()
Constructs a new mutable activity.MutableActivityBase(String name)
Constructs a new mutable activity with the given name.MutableActivityBase(String name, Instant startTime, Instant endTime)
Constructs a new mutable activity with the given name, start time, and end time.MutableActivityBase(Instant startTime, Instant endTime)
Constructs a new mutable activity with the start time and end time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDuration(Duration duration)
Convenience method to determine a new end time based on a duration that will be added once to the current end time of the activity.void
addDuration(Duration duration, long multipliedBy)
Convenience method to determine a new end time based on a duration that will be added several times to the current end time of the activity.Duration
getDuration()
Convenience method to determine the duration between the start and the end time of the activity.void
setDuration(Duration duration)
Convenience method to determine a new end time based on a duration that will be added to the current start time of the activity.void
setEndTime(Instant time)
Sets a new end time on the activity.void
setName(String name)
Sets the name of the activity.void
setStartTime(Instant time)
Sets a new start time on the activity.-
Methods inherited from class com.flexganttfx.model.activity.ActivityBase
getEndTime, getId, getName, getStartTime, getUserObject, setUserObject, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.flexganttfx.model.Activity
getEndTime, getId, getName, getStartTime
-
-
-
-
Constructor Detail
-
MutableActivityBase
public MutableActivityBase()
Constructs a new mutable activity. The initial start time will be set toInstant.now()
and the end time will be equal toInstant.now()
plus the value ofActivityBase.DEFAULT_DURATION
.- Since:
- 1.0
-
MutableActivityBase
public MutableActivityBase(String name)
Constructs a new mutable activity with the given name. The initial start time will be set toInstant.now()
and the end time will be equal toInstant.now()
plus the value ofActivityBase.DEFAULT_DURATION
.- Parameters:
name
- the name of the activity- Since:
- 1.0
-
MutableActivityBase
public MutableActivityBase(Instant startTime, Instant endTime)
Constructs a new mutable activity with the start time and end time.- Parameters:
startTime
- the start time of the activityendTime
- the end time of the activity- Since:
- 1.0
-
MutableActivityBase
public MutableActivityBase(String name, Instant startTime, Instant endTime)
Constructs a new mutable activity with the given name, start time, and end time.- Parameters:
name
- the name of the activitystartTime
- the start time of the activityendTime
- the end time of the activity- Since:
- 1.0
-
-
Method Detail
-
setName
public void setName(String name)
Description copied from interface:MutableActivity
Sets the name of the activity.- Specified by:
setName
in interfaceMutableActivity
- Parameters:
name
- the new name of the activity
-
setStartTime
public void setStartTime(Instant time)
Description copied from interface:MutableActivity
Sets a new start time on the activity.- Specified by:
setStartTime
in interfaceMutableActivity
- Parameters:
time
- the new start time
-
setEndTime
public void setEndTime(Instant time)
Description copied from interface:MutableActivity
Sets a new end time on the activity.- Specified by:
setEndTime
in interfaceMutableActivity
- Parameters:
time
- the new end time
-
setDuration
public void setDuration(Duration duration)
Convenience method to determine a new end time based on a duration that will be added to the current start time of the activity.- Parameters:
duration
- the duration of the activity- Since:
- 1.0
-
getDuration
public Duration getDuration()
Convenience method to determine the duration between the start and the end time of the activity.- Returns:
- the duration of the activity
-
addDuration
public void addDuration(Duration duration)
Convenience method to determine a new end time based on a duration that will be added once to the current end time of the activity.- Parameters:
duration
- the duration of the activity- Since:
- 1.0
-
addDuration
public void addDuration(Duration duration, long multipliedBy)
Convenience method to determine a new end time based on a duration that will be added several times to the current end time of the activity.- Parameters:
duration
- the duration of the activitymultipliedBy
- the number of times that the duration will be added- Since:
- 1.0
-
-