Package com.helger.dao
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 TypeMethodDescriptionvoidStart doing something without auto save.voidEnd doing something without auto save.booleandefault 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 Details
-
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
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 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 EXTYPEExecute 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 error
-