Class HistoryManager

java.lang.Object
net.mcreator.workspace.localhistory.HistoryManager
All Implemented Interfaces:
AutoCloseable

public final class HistoryManager extends Object implements AutoCloseable
  • Constructor Details

    • HistoryManager

      public HistoryManager(Workspace workspace)
  • Method Details

    • checkpoint

      public void checkpoint(String checkpointName, Object... parameters)
      Saves checkpoint with a given name.
      Parameters:
      checkpointName - Checkpoint name should reflect the current state of the workspace at the time of the checkpoint.
    • importantCheckpoint

      public void importantCheckpoint(String checkpointName, Object... parameters)
      Creates an important checkpoint in the history with the specified name. This method will block if the local history backend is busy until the checkpoint is written.
      Parameters:
      checkpointName - The name of the checkpoint. This name should represent the current state of the workspace when the checkpoint is created.
      parameters - Additional parameters related to the checkpoint that can provide further context or metadata for the checkpoint event.
    • importantCheckpoint

      public void importantCheckpoint(@Nullable Supplier<Boolean> ifImportantBusySyncWriteConfirm, String checkpointName, Object... parameters)
      Creates an important checkpoint in the history with the specified name. This method allows specifying additional parameters and an optional synchronization mechanism.
      Parameters:
      ifImportantBusySyncWriteConfirm - A supplier that provides a boolean indicating whether the checkpoint should be written synchronously during a busy state. If null, the checkpoint is always written synchronously by default.
      checkpointName - The name of the checkpoint. This name should represent the current state of the workspace when the checkpoint is created.
      parameters - Additional parameters related to the checkpoint that can provide further context or metadata for the checkpoint event.
    • setCheckpointListener

      public void setCheckpointListener(@Nullable Runnable listener)
    • setBusyListener

      public void setBusyListener(@Nullable Consumer<Boolean> listener)
    • getCheckpoints

      public void getCheckpoints(Consumer<List<HistoryCheckpoint>> callback)
    • optimizeStorage

      public void optimizeStorage()
    • revertToCheckpoint

      public void revertToCheckpoint(HistoryCheckpoint checkpoint) throws LocalHistoryException
      Throws:
      LocalHistoryException
    • isAvailable

      public boolean isAvailable()
    • isBusy

      public boolean isBusy()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getLocalHistoryRoot

      public static File getLocalHistoryRoot(File workspaceFolder)