Interface Action<T>

Type Parameters:
T - The type of the result returned by the run method.
All Known Subinterfaces:
DirtyAction<T>, DirtyVoidAction, VoidAction
All Known Implementing Classes:
AbstractAction, ConstructorAction

public interface Action<T>
Represents an action that can be executed and undone by either the app or the user affecting the scene. Implementations of the interface provide the logic for executing and undoing the action themselves.

This interface has multiple other versions for return type clarity.

Author:
Lehlogonolo Poole
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Provides a description of the action.
    default ActionPanel
    Provides a default implementation for getting an ActionPanel associated with this action.
    Returns the time at which the action was performed.
    boolean
    Checks if the action is reversible.
    run()
    Executes the action.
    void
    Undoes the action.
  • Method Details

    • run

      T run()
      Executes the action.
      Returns:
      The result of the action.
    • undo

      void undo()
      Undoes the action.
    • isReversible

      boolean isReversible()
      Checks if the action is reversible.
      Returns:
      true if the action can be undone, false otherwise.
    • getDescription

      String getDescription()
      Provides a description of the action. This description is printed to both the debug console and the history log (UI).
      Returns:
      A string describing the action.
    • getTime

      LocalTime getTime()
      Returns the time at which the action was performed.
      Returns:
      The time of the action.
    • getPanel

      default ActionPanel getPanel()
      Provides a default implementation for getting an ActionPanel associated with this action.
      Returns:
      An ActionPanel instance.