Class AbstactTask

  • All Implemented Interfaces:
    Task, java.lang.Iterable<Task>
    Direct Known Subclasses:
    AnonymousTask, DirectoryTask, FolderTask, LeafTask

    public abstract class AbstactTask
    extends java.lang.Object
    implements Task
    This is a simple base implementation of a Task.
    Author:
    alexxismachine (Ulrich David)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected TaskState state
      The state of this task.
      protected java.util.Collection<Task> subTasks
      The sub tasks of this task.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstactTask​(Task parent, java.lang.String description)
      Create a task with the given parameter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChild​(Task task)
      Add a child to the task. (???
      void addContent​(java.lang.String line)
      Add a line to the content collection.
      java.util.List<java.lang.String> getContent()
      Get the content collection.
      java.lang.String getDescription()
      Get the tasks description.
      Task getParent()
      Get the praent task.
      short getPriority()
      Get the priority, The lower the number the higher the priority.
      boolean hasChildren()
      Tell if there are children to the task.
      boolean isInState​(TaskState status)
      Tell if the task is in the asked status.
      java.util.Iterator<Task> iterator()  
      java.util.List<java.lang.Short> priorities()
      Get the priorities that this task and all the sub tasks are in.
      void setPriority​(short priority)
      Set the priority.
      void setState​(TaskState state)
      Set the state of the Task
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • subTasks

        protected java.util.Collection<Task> subTasks
        The sub tasks of this task.
      • state

        protected TaskState state
        The state of this task.
    • Constructor Detail

      • AbstactTask

        protected AbstactTask​(Task parent,
                              java.lang.String description)
        Create a task with the given parameter.
        Parameters:
        parent - the parent task.
        description - the description.
    • Method Detail

      • setState

        public void setState​(TaskState state)
        Set the state of the Task
        Parameters:
        state - the new state.
      • isInState

        public boolean isInState​(TaskState status)
        Description copied from interface: Task
        Tell if the task is in the asked status. A task is in a status if itself or one of the children is in that status. If given status is null must return true.
        Specified by:
        isInState in interface Task
        Parameters:
        status - the task state
        Returns:
        true if the task is in the asked status.
      • iterator

        public java.util.Iterator<Task> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Task>
      • hasChildren

        public boolean hasChildren()
        Description copied from interface: Task
        Tell if there are children to the task.
        Specified by:
        hasChildren in interface Task
        Returns:
        true if there are children.
      • addChild

        public void addChild​(Task task)
        Description copied from interface: Task
        Add a child to the task. (??? Sets the parent of the added task to this???).
        Specified by:
        addChild in interface Task
        Parameters:
        task - the task to add.
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: Task
        Get the tasks description.
        Specified by:
        getDescription in interface Task
        Returns:
        the description.
      • getParent

        public Task getParent()
        Description copied from interface: Task
        Get the praent task.
        Specified by:
        getParent in interface Task
        Returns:
        the parent task. null if there is no parent.
      • getContent

        public java.util.List<java.lang.String> getContent()
        Description copied from interface: Task
        Get the content collection.
        Specified by:
        getContent in interface Task
        Returns:
        the content collection. MUST NOT be null. MAY be an unmodifiable collection.
      • addContent

        public void addContent​(java.lang.String line)
        Description copied from interface: Task
        Add a line to the content collection.
        Specified by:
        addContent in interface Task
        Parameters:
        line - the line to add.
      • getPriority

        public short getPriority()
        Get the priority, The lower the number the higher the priority.
        Specified by:
        getPriority in interface Task
        Returns:
        the priority. '0' if not specified.
      • setPriority

        public void setPriority​(short priority)
        Set the priority.
        Parameters:
        priority - the new priority.
      • priorities

        public java.util.List<java.lang.Short> priorities()
        Get the priorities that this task and all the sub tasks are in.

        This implementation returns the own and all sub task priorities.

        Specified by:
        priorities in interface Task
        Returns:
        the priorities;