Class AbstractTask

    • Field Detail

      • PROPERTY_CONDITION

        public static final java.lang.String PROPERTY_CONDITION
        The task condition property.
        See Also:
        Constant Field Values
      • finished

        protected boolean finished
        The finished flag.
      • condition

        protected IBooleanCondition condition
        The task condition (optional). Task is executed as long as the condition is true.
    • Constructor Detail

      • AbstractTask

        public AbstractTask()
    • Method Detail

      • start

        public void start​(ISpaceObject obj)
        This method will be executed by the object before the task gets added to the execution queue. Empty default implementation that can be replaced by subclasses.
        Specified by:
        start in interface IObjectTask
        Parameters:
        space - The environment in which the task is executing.
        obj - The object that is executing the task.
      • shutdown

        public void shutdown​(ISpaceObject obj)
        This method will be executed by the object before the task is removed from the execution queue. Notifies the listener and hence should be called when overridden in subclasses.
        Specified by:
        shutdown in interface IObjectTask
        Parameters:
        space - The environment in which the task is executing.
        obj - The object that is executing the task.
      • execute

        public void execute​(IEnvironmentSpace space,
                            ISpaceObject obj,
                            long progress,
                            IClockService clock)
        Executes the task.
        Specified by:
        execute in interface IObjectTask
        Parameters:
        space - The environment in which the task is executing.
        obj - The object that is executing the task.
        progress - The time that has passed according to the environment executor.
        clock - The clock service.
      • isFinished

        public boolean isFinished​(IEnvironmentSpace space,
                                  ISpaceObject obj)
        Check if a task is finished and should be removed. Finished tasks will no longer be executed.
        Specified by:
        isFinished in interface IObjectTask
        Returns:
        True, if the task is finished.
      • setFinished

        public void setFinished​(IEnvironmentSpace space,
                                ISpaceObject obj,
                                boolean finished)
        Indicate that the task is finished and should be removed.
        Parameters:
        space - The environment in which the task is executing.
        obj - The object that is executing the task.
        finished - The finished flag.