Class CommandHistorySaver

java.lang.Object
net.minheur.potoflux.terminal.CommandHistorySaver

public class CommandHistorySaver extends Object
Store, handle and save the command history
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    History length.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<String>
    get()
    Getter for the entire history
    static void
    loadFrom(List<String> pHistory)
    Load all history from another list, after clearing all existing commands.
    static void
    save(String command)
    Save a command to the history.
    If the command is already the lastest, do nothing.
    Inserts the command in the first position, then if the history is already full, remove the last command.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_SIZE

      public static final int MAX_SIZE
      History length. There is no more commands stored as this number.
      See Also:
  • Constructor Details

    • CommandHistorySaver

      public CommandHistorySaver()
  • Method Details

    • save

      public static void save(String command)
      Save a command to the history.
      If the command is already the lastest, do nothing.
      Inserts the command in the first position, then if the history is already full, remove the last command.
      Parameters:
      command - to store in the history
    • get

      public static List<String> get()
      Getter for the entire history
      Returns:
      history
    • loadFrom

      public static void loadFrom(List<String> pHistory)
      Load all history from another list, after clearing all existing commands.
      Parameters:
      pHistory - list to load from