Package com.helger.dao
Interface IAutoSaveAware
-
- All Known Subinterfaces:
IDAO,IDAOContainer
- All Known Implementing Classes:
AbstractDAO,AbstractDAOContainer,AbstractMapBasedWALDAO,AbstractSimpleDAO,AbstractWALDAO,DefaultDAOContainer
public interface IAutoSaveAwareAbstraction layer around auto save stuff.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidbeginWithoutAutoSave()Start doing something without auto save.voidendWithoutAutoSave()End doing something without auto save.booleanisAutoSaveEnabled()default voidperformWithoutAutoSave(Runnable aRunnable)This method is used for batch processing of instructions (like the initial read).default <RETURNTYPE>
RETURNTYPEperformWithoutAutoSave(Supplier<RETURNTYPE> aCallable)This method is used for batch processing of instructions (like the initial read).default <EXTYPE extends Exception>
voidperformWithoutAutoSaveThrowing(com.helger.commons.callback.IThrowingRunnable<EXTYPE> aRunnable)Execute a callback with autosave being disabled.default <RETURNTYPE,EXTYPE extends Exception>
RETURNTYPEperformWithoutAutoSaveThrowing(com.helger.commons.functional.IThrowingSupplier<RETURNTYPE,EXTYPE> aCallable)Execute a callback with autosave being disabled.
-
-
-
Method Detail
-
isAutoSaveEnabled
boolean isAutoSaveEnabled()
- Returns:
trueif auto save is enabled,falseotherwise.
-
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 tobeginWithoutAutoSave()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 benull.
-
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 benull.- Returns:
- the result of the callable.
-
performWithoutAutoSaveThrowing
default <EXTYPE extends Exception> void performWithoutAutoSaveThrowing(@Nonnull com.helger.commons.callback.IThrowingRunnable<EXTYPE> aRunnable) throws EXTYPE extends Exception
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 errorEXTYPE extends Exception
-
performWithoutAutoSaveThrowing
@Nullable default <RETURNTYPE,EXTYPE extends Exception> RETURNTYPE performWithoutAutoSaveThrowing(@Nonnull com.helger.commons.functional.IThrowingSupplier<RETURNTYPE,EXTYPE> aCallable) throws EXTYPE extends Exception
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 callableEXTYPE- 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 errorEXTYPE extends Exception
-
-