Interface IAutoSaveAware

All Known Subinterfaces:
IDAO, IDAOContainer
All Known Implementing Classes:
AbstractDAO, AbstractDAOContainer, AbstractMapBasedWALDAO, AbstractSimpleDAO, AbstractWALDAO, DefaultDAOContainer

public interface IAutoSaveAware
Abstraction layer around auto save stuff.
Author:
Philip Helger
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Start doing something without auto save.
    void
    End doing something without auto save.
    boolean
     
    default void
    This method is used for batch processing of instructions (like the initial read).
    default <RETURNTYPE>
    RETURNTYPE
    performWithoutAutoSave(Supplier<RETURNTYPE> aCallable)
    This method is used for batch processing of instructions (like the initial read).
    default <EXTYPE extends Exception>
    void
    performWithoutAutoSaveThrowing(com.helger.commons.callback.IThrowingRunnable<EXTYPE> aRunnable)
    Execute a callback with autosave being disabled.
    default <RETURNTYPE, EXTYPE extends Exception>
    RETURNTYPE
    performWithoutAutoSaveThrowing(com.helger.commons.functional.IThrowingSupplier<RETURNTYPE,EXTYPE> aCallable)
    Execute a callback with autosave being disabled.
  • Method Details

    • isAutoSaveEnabled

      boolean isAutoSaveEnabled()
      Returns:
      true if auto save is enabled, false otherwise.
    • beginWithoutAutoSave

      void beginWithoutAutoSave()
      Start doing something without auto save.
    • endWithoutAutoSave

      void endWithoutAutoSave()
      End doing something without auto save. It must be ensure that each call to beginWithoutAutoSave() is always correctly ended with a call to this method.
    • performWithoutAutoSave

      default void performWithoutAutoSave(@Nonnull Runnable aRunnable)
      This method is used for batch processing of instructions (like the initial read). If first turns automatic saving off, runs the desired operations and finally restores the initial state of the "automatic save" flag and tries to write any pending changes.
      Parameters:
      aRunnable - The runnable to be executed. May not be null.
    • performWithoutAutoSave

      @Nullable default <RETURNTYPE> RETURNTYPE performWithoutAutoSave(@Nonnull Supplier<RETURNTYPE> aCallable)
      This method is used for batch processing of instructions (like the initial read). If first turns automatic saving off, runs the desired operations and finally restores the initial state of the "automatic save" flag and tries to write any pending changes.
      Type Parameters:
      RETURNTYPE - Return type of the callable
      Parameters:
      aCallable - The runnable to be executed. May not be null.
      Returns:
      the result of the callable.
    • performWithoutAutoSaveThrowing

      default <EXTYPE extends Exception> void performWithoutAutoSaveThrowing(@Nonnull com.helger.commons.callback.IThrowingRunnable<EXTYPE> aRunnable) throws EXTYPE
      Execute a callback with autosave being disabled. Must be called outside a writeLock, as this method locks itself!
      Type Parameters:
      EXTYPE - Exception type that may be thrown
      Parameters:
      aRunnable - The callback to be executed
      Throws:
      EXTYPE - In case of an error
    • performWithoutAutoSaveThrowing

      @Nullable default <RETURNTYPE, EXTYPE extends Exception> RETURNTYPE performWithoutAutoSaveThrowing(@Nonnull com.helger.commons.functional.IThrowingSupplier<RETURNTYPE,EXTYPE> aCallable) throws EXTYPE
      Execute a callback with autosave being disabled. Must be called outside a writeLock, as this method locks itself!
      Type Parameters:
      RETURNTYPE - Return type of the callable
      EXTYPE - Exception type that may be thrown
      Parameters:
      aCallable - The callback to be executed
      Returns:
      The result of the callback. May be null.
      Throws:
      EXTYPE - In case of an error