Package com.helger.dao.wal
Class AbstractMapBasedWALDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>,IMPLTYPE extends INTERFACETYPE>
- java.lang.Object
-
- com.helger.dao.AbstractDAO
-
- com.helger.dao.wal.AbstractWALDAO<IMPLTYPE>
-
- com.helger.dao.wal.AbstractMapBasedWALDAO<INTERFACETYPE,IMPLTYPE>
-
- Type Parameters:
INTERFACETYPE- Interface type to be handledIMPLTYPE- Implementation type to be handled
- All Implemented Interfaces:
com.helger.commons.lang.IHasSize,com.helger.commons.log.IHasConditionalLogger,IAutoSaveAware,IDAO,IMapBasedDAO<INTERFACETYPE>
@ThreadSafe public abstract class AbstractMapBasedWALDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>,IMPLTYPE extends INTERFACETYPE> extends AbstractWALDAO<IMPLTYPE> implements IMapBasedDAO<INTERFACETYPE>
Base class for WAL based DAO that uses a simpleICommonsMapfor data storage.- Author:
- Philip Helger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractMapBasedWALDAO.InitSettings<IMPLTYPE>Extensible constructor parameter builder.-
Nested classes/interfaces inherited from interface com.helger.dao.IDAO
IDAO.EMode
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringELEMENT_ITEMprotected static StringELEMENT_ROOT-
Fields inherited from class com.helger.dao.wal.AbstractWALDAO
DEFAULT_WAITING_TIME, WAL_XWS, WRITE_XWS
-
Fields inherited from class com.helger.dao.AbstractDAO
CONDLOG, DEFAULT_AUTO_SAVE_ENABLED, FILENAME_EXTENSION_NEW, FILENAME_EXTENSION_PREV, m_aRWLock, RW_LOCK
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMapBasedWALDAO(Class<IMPLTYPE> aImplClass, com.helger.commons.io.relative.IFileRelativeIO aIO, String sFilename, AbstractMapBasedWALDAO.InitSettings<IMPLTYPE> aInitSettings)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description com.helger.commons.callback.CallbackList<IDAOChangeCallback<INTERFACETYPE>>callbacks()booleancontainsAllIDs(Iterable<String> aIDs)Check if all IDs are containedbooleancontainsAny(Predicate<? super INTERFACETYPE> aFilter)booleancontainsNone(Predicate<? super INTERFACETYPE> aFilter)booleancontainsOnly(Predicate<? super INTERFACETYPE> aFilter)booleancontainsWithID(String sID)protected com.helger.xml.microdom.IMicroDocumentcreateWriteData()Create the XML document that should be saved to the file.voidfindAll(Predicate<? super INTERFACETYPE> aFilter, Consumer<? super INTERFACETYPE> aConsumer)Find all items matching the filter and invoke the consumer on all matching entries.<RETTYPE> voidfindAllMapped(Predicate<? super INTERFACETYPE> aFilter, Function<? super INTERFACETYPE,? extends RETTYPE> aMapper, Consumer<? super RETTYPE> aConsumer)Find all contained items that match the filter, map them to a different type and invoke the consumer on all mapped items.INTERFACETYPEfindFirst(Predicate<? super INTERFACETYPE> aFilter)Find the the first element that matches the filter.<RETTYPE> RETTYPEfindFirstMapped(Predicate<? super INTERFACETYPE> aFilter, Function<? super INTERFACETYPE,? extends RETTYPE> aMapper)voidforEach(BiConsumer<? super String,? super INTERFACETYPE> aConsumer)Iterate each entryvoidforEach(BiPredicate<? super String,? super INTERFACETYPE> aFilter, BiConsumer<? super String,? super INTERFACETYPE> aConsumer)Iterate each entryvoidforEachKey(Consumer<? super String> aConsumer)Iterate each keyvoidforEachKey(Predicate<? super String> aFilter, Consumer<? super String> aConsumer)Iterate each keyvoidforEachValue(Consumer<? super INTERFACETYPE> aConsumer)Iterate each valuevoidforEachValue(Predicate<? super INTERFACETYPE> aFilter, Consumer<? super INTERFACETYPE> aConsumer)Iterate each valuecom.helger.commons.collection.impl.ICommonsList<INTERFACETYPE>getAll()com.helger.commons.collection.impl.ICommonsList<INTERFACETYPE>getAll(Predicate<? super INTERFACETYPE> aFilter)com.helger.commons.collection.impl.ICommonsSet<String>getAllIDs()<RETTYPE> com.helger.commons.collection.impl.ICommonsList<RETTYPE>getAllMapped(Predicate<? super INTERFACETYPE> aFilter, Function<? super INTERFACETYPE,? extends RETTYPE> aMapper)Get all contained items matching the provided filter and map them to something else.protected INTERFACETYPEgetAtIndex(int nIndex)Get the item at the specified index.intgetCount(Predicate<? super INTERFACETYPE> aFilter)<T> com.helger.commons.collection.impl.ICommonsList<T>getNone()protected IMPLTYPEgetOfID(String sID)Find the element with the provided ID.protected booleaninternalContainsWithID(String sID)protected IMPLTYPEinternalCreateItem(IMPLTYPE aNewItem)Add an item including invoking the callback.protected IMPLTYPEinternalCreateItem(IMPLTYPE aNewItem, boolean bInvokeCallbacks)Add an item including invoking the callback.protected IMPLTYPEinternalDeleteItem(String sID)Delete the item by removing it from the map.protected IMPLTYPEinternalDeleteItem(String sID, boolean bInvokeCallbacks)Delete the item by removing it from the map.protected Iterable<IMPLTYPE>internalDirectGetAll()protected voidinternalForEachValue(Consumer<? super IMPLTYPE> aConsumer)protected voidinternalForEachValue(Predicate<? super IMPLTYPE> aFilter, Consumer<? super IMPLTYPE> aConsumer)protected com.helger.commons.collection.impl.ICommonsList<IMPLTYPE>internalGetAll(Predicate<? super IMPLTYPE> aFilter)protected Collection<IMPLTYPE>internalGetAllSortedByKey()protected IMPLTYPEinternalGetOfID(String sID)Same asgetOfID(String)but the locking must happen on the called side.protected voidinternalMarkItemDeleted(IMPLTYPE aItem)Mark an item as "deleted" without actually deleting it from the map.protected voidinternalMarkItemDeleted(IMPLTYPE aItem, boolean bInvokeCallbacks)Mark an item as "deleted" without actually deleting it from the map.protected voidinternalMarkItemUndeleted(IMPLTYPE aItem)Mark an item as "no longer deleted" without actually adding it to the map.protected voidinternalMarkItemUndeleted(IMPLTYPE aItem, boolean bInvokeCallbacks)Mark an item as "no longer deleted" without actually adding it to the map.protected com.helger.commons.state.EChangeinternalRemoveAllItemsNoCallback()Remove all items without triggering any callback.protected voidinternalUpdateItem(IMPLTYPE aItem)Update an existing item including invoking the callback.protected voidinternalUpdateItem(IMPLTYPE aItem, boolean bInvokeCallbacks)Update an existing item including invoking the callback.booleanisEmpty()booleanisNotEmpty()protected voidmarkAsChanged(IMPLTYPE aModifiedElement, EDAOActionType eActionType)Deprecated.Avoid that this method is overriddenprotected com.helger.commons.state.EChangeonRead(com.helger.xml.microdom.IMicroDocument aDoc)Fill the internal structures with from the passed XML document.protected voidonRecoveryCreate(IMPLTYPE aItem)Called when a recovery is needed to create a new item.protected voidonRecoveryDelete(IMPLTYPE aItem)Called when a recovery is needed to delete an existing item.protected voidonRecoveryUpdate(IMPLTYPE aItem)Called when a recovery is needed to update an existing item.intsize()StringtoString()-
Methods inherited from class com.helger.dao.wal.AbstractWALDAO
convertNativeToWALString, convertWALStringToNative, getDataTypeClass, getFilenameProvider, getInitCount, getIO, getLastFilename, getLastInitDateTime, getLastReadDateTime, getLastWriteDateTime, getReadCount, getSafeFile, getWaitingTime, getWALXMLWriterSettings, getWriteCount, getXMLWriterSettings, initialRead, markAsChanged, modifyWriteData, onBetweenReadAndWAL, onFilenameChange, onInit, onRecoveryErrorConvertToNative, setWaitingTime, triggerExceptionHandlersRead, triggerExceptionHandlersWrite, writeToFileOnPendingChanges
-
Methods inherited from class com.helger.dao.AbstractDAO
beginWithoutAutoSave, checkFileAccess, endWithoutAutoSave, exceptionHandlersRead, exceptionHandlersWrite, hasPendingChanges, internalHasPendingChanges, internalIsAutoSaveEnabled, internalSetPendingChanges, isAutoSaveEnabled, isSilentMode, setSilentMode
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.dao.IAutoSaveAware
performWithoutAutoSave, performWithoutAutoSave, performWithoutAutoSaveThrowing, performWithoutAutoSaveThrowing
-
Methods inherited from interface com.helger.dao.IDAO
isReloadable, reload
-
-
-
-
Field Detail
-
ELEMENT_ROOT
protected static final String ELEMENT_ROOT
- See Also:
- Constant Field Values
-
ELEMENT_ITEM
protected static final String ELEMENT_ITEM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractMapBasedWALDAO
protected AbstractMapBasedWALDAO(@Nonnull Class<IMPLTYPE> aImplClass, @Nonnull com.helger.commons.io.relative.IFileRelativeIO aIO, @Nullable String sFilename, @Nonnull AbstractMapBasedWALDAO.InitSettings<IMPLTYPE> aInitSettings) throws DAOException
Default constructor. Automatically tries to read the file in the constructor (except this is changed in the init settings). WAL based classes must have a fixed filename!- Parameters:
aImplClass- Implementation class. May not benull.aIO- IO abstraction to be used. May not benull.sFilename- The filename to read and write.aInitSettings- Optional initialization settings to be used. May not benull.- Throws:
DAOException- If reading and reading fails
-
-
Method Detail
-
onRecoveryCreate
@MustBeLocked(WRITE) protected void onRecoveryCreate(@Nonnull IMPLTYPE aItem)
Description copied from class:AbstractWALDAOCalled when a recovery is needed to create a new item.- Specified by:
onRecoveryCreatein classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Parameters:
aItem- The element to be created. Nevernull.
-
onRecoveryUpdate
@MustBeLocked(WRITE) protected void onRecoveryUpdate(@Nonnull IMPLTYPE aItem)
Description copied from class:AbstractWALDAOCalled when a recovery is needed to update an existing item.- Specified by:
onRecoveryUpdatein classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Parameters:
aItem- The element to be updated. Nevernull.
-
onRecoveryDelete
@MustBeLocked(WRITE) protected void onRecoveryDelete(@Nonnull IMPLTYPE aItem)
Description copied from class:AbstractWALDAOCalled when a recovery is needed to delete an existing item.- Specified by:
onRecoveryDeletein classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Parameters:
aItem- The element to be deleted. Nevernull.
-
onRead
@Nonnull protected com.helger.commons.state.EChange onRead(@Nonnull com.helger.xml.microdom.IMicroDocument aDoc)
Description copied from class:AbstractWALDAOFill the internal structures with from the passed XML document. This method is only called within a write lock!- Specified by:
onReadin classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Parameters:
aDoc- The XML document to read from. Nevernull.- Returns:
EChange.CHANGEDif reading the data changed something in the internal structures that requires a writing.
-
internalGetAllSortedByKey
@MustBeLocked(READ) @CodingStyleguideUnaware protected final Collection<IMPLTYPE> internalGetAllSortedByKey()
-
createWriteData
@Nonnull @MustBeLocked(READ) protected com.helger.xml.microdom.IMicroDocument createWriteData()
Description copied from class:AbstractWALDAOCreate the XML document that should be saved to the file. This method is only called within a write lock!- Specified by:
createWriteDatain classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Returns:
- The non-
nulldocument to write to the file.
-
callbacks
@Nonnull @ReturnsMutableObject public final com.helger.commons.callback.CallbackList<IDAOChangeCallback<INTERFACETYPE>> callbacks()
-
markAsChanged
@MustBeLocked(WRITE) @Deprecated @DevelopersNote("Avoid that this method is overridden") protected final void markAsChanged(@Nonnull IMPLTYPE aModifiedElement, @Nonnull EDAOActionType eActionType)
Deprecated.Avoid that this method is overriddenThe super method must be called every time something changed in the DAO. It triggers the writing to a file if auto-save is active. This method must be called within a write-lock as it is not locked!- Overrides:
markAsChangedin classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>- Parameters:
aModifiedElement- The modified data element. May not benull.eActionType- The action that was performed. May not benull.
-
internalCreateItem
@MustBeLocked(WRITE) @Nonnull protected final IMPLTYPE internalCreateItem(@Nonnull IMPLTYPE aNewItem)
Add an item including invoking the callback. Must only be invoked inside a write-lock.- Parameters:
aNewItem- The item to be added. May not benull.- Returns:
- The passed parameter as-is. Never
null. - Throws:
IllegalArgumentException- If an item with the same ID is already contained
-
internalCreateItem
@MustBeLocked(WRITE) @Nonnull protected final IMPLTYPE internalCreateItem(@Nonnull IMPLTYPE aNewItem, boolean bInvokeCallbacks)
Add an item including invoking the callback. Must only be invoked inside a write-lock.- Parameters:
aNewItem- The item to be added. May not benull.bInvokeCallbacks-trueto invoke callbacks,falseto not do so.- Returns:
- The passed parameter as-is. Never
null. - Throws:
IllegalArgumentException- If an item with the same ID is already contained- Since:
- 9.2.1
-
internalUpdateItem
@MustBeLocked(WRITE) protected final void internalUpdateItem(@Nonnull IMPLTYPE aItem)
Update an existing item including invoking the callback. Must only be invoked inside a write-lock.- Parameters:
aItem- The item to be updated. May not benull.- Throws:
IllegalArgumentException- If no item with the same ID is already contained
-
internalUpdateItem
@MustBeLocked(WRITE) protected final void internalUpdateItem(@Nonnull IMPLTYPE aItem, boolean bInvokeCallbacks)
Update an existing item including invoking the callback. Must only be invoked inside a write-lock.- Parameters:
aItem- The item to be updated. May not benull.bInvokeCallbacks-trueto invoke callbacks,falseto not do so.- Throws:
IllegalArgumentException- If no item with the same ID is already contained- Since:
- 9.2.1
-
internalDeleteItem
@MustBeLocked(WRITE) @Nullable protected final IMPLTYPE internalDeleteItem(@Nullable String sID)
Delete the item by removing it from the map. If something was remove the onDeleteItem callback is invoked. Must only be invoked inside a write-lock.- Parameters:
sID- The ID to be removed. May benull.- Returns:
- The deleted item. If
nullno such item was found and therefore nothing was removed.
-
internalDeleteItem
@MustBeLocked(WRITE) @Nullable protected final IMPLTYPE internalDeleteItem(@Nullable String sID, boolean bInvokeCallbacks)
Delete the item by removing it from the map. If something was remove the onDeleteItem callback is invoked. Must only be invoked inside a write-lock.- Parameters:
sID- The ID to be removed. May benull.bInvokeCallbacks-trueto invoke callbacks,falseto not do so.- Returns:
- The deleted item. If
nullno such item was found and therefore nothing was removed. - Since:
- 9.2.1
-
internalMarkItemDeleted
@MustBeLocked(WRITE) protected final void internalMarkItemDeleted(@Nonnull IMPLTYPE aItem)
Mark an item as "deleted" without actually deleting it from the map. This method only triggers the update action but does not alter the item. Must only be invoked inside a write-lock.- Parameters:
aItem- The item that was marked as "deleted"
-
internalMarkItemDeleted
@MustBeLocked(WRITE) protected final void internalMarkItemDeleted(@Nonnull IMPLTYPE aItem, boolean bInvokeCallbacks)
Mark an item as "deleted" without actually deleting it from the map. This method only triggers the update action but does not alter the item. Must only be invoked inside a write-lock.- Parameters:
aItem- The item that was marked as "deleted"bInvokeCallbacks-trueto invoke callbacks,falseto not do so.- Since:
- 9.2.1
-
internalMarkItemUndeleted
@MustBeLocked(WRITE) protected final void internalMarkItemUndeleted(@Nonnull IMPLTYPE aItem)
Mark an item as "no longer deleted" without actually adding it to the map. This method only triggers the update action but does not alter the item. Must only be invoked inside a write-lock.- Parameters:
aItem- The item that was marked as "no longer deleted"
-
internalMarkItemUndeleted
@MustBeLocked(WRITE) protected final void internalMarkItemUndeleted(@Nonnull IMPLTYPE aItem, boolean bInvokeCallbacks)
Mark an item as "no longer deleted" without actually adding it to the map. This method only triggers the update action but does not alter the item. Must only be invoked inside a write-lock.- Parameters:
aItem- The item that was marked as "no longer deleted"bInvokeCallbacks-trueto invoke callbacks,falseto not do so.- Since:
- 9.2.1
-
internalRemoveAllItemsNoCallback
@MustBeLocked(WRITE) @Nonnull protected final com.helger.commons.state.EChange internalRemoveAllItemsNoCallback()
Remove all items without triggering any callback. Must only be invoked inside a write-lock.- Returns:
EChange.CHANGEDif something was contained,EChange.UNCHANGEDotherwise.
-
getNone
@Nonnull @ReturnsMutableCopy public final <T> com.helger.commons.collection.impl.ICommonsList<T> getNone()
- Specified by:
getNonein interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Type Parameters:
T- Response type.- Returns:
- An empty collection of the suitable implementation type.
-
getAll
@Nonnull @ReturnsMutableCopy @IsLocked(READ) public final com.helger.commons.collection.impl.ICommonsList<INTERFACETYPE> getAll()
- Specified by:
getAllin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Returns:
- A list of all contained items. Never
null.
-
getAll
@Nonnull @ReturnsMutableCopy @IsLocked(READ) public final com.helger.commons.collection.impl.ICommonsList<INTERFACETYPE> getAll(@Nullable Predicate<? super INTERFACETYPE> aFilter)
- Specified by:
getAllin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- Filter to be applied. May benull.- Returns:
- A list of all contained items matching the filter. Never
null.
-
internalDirectGetAll
@Nonnull @ReturnsMutableCopy @IsLocked(READ) protected final Iterable<IMPLTYPE> internalDirectGetAll()
-
internalGetAll
@Nonnull @ReturnsMutableCopy @IsLocked(READ) protected final com.helger.commons.collection.impl.ICommonsList<IMPLTYPE> internalGetAll(@Nullable Predicate<? super IMPLTYPE> aFilter)
-
findAll
@IsLocked(READ) public final void findAll(@Nullable Predicate<? super INTERFACETYPE> aFilter, @Nonnull Consumer<? super INTERFACETYPE> aConsumer)
Description copied from interface:IMapBasedDAOFind all items matching the filter and invoke the consumer on all matching entries.- Specified by:
findAllin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.aConsumer- The consumer to be invoked for all matches. May not benull.
-
getAllMapped
@Nonnull @ReturnsMutableCopy @IsLocked(READ) public final <RETTYPE> com.helger.commons.collection.impl.ICommonsList<RETTYPE> getAllMapped(@Nullable Predicate<? super INTERFACETYPE> aFilter, @Nonnull Function<? super INTERFACETYPE,? extends RETTYPE> aMapper)
Description copied from interface:IMapBasedDAOGet all contained items matching the provided filter and map them to something else.- Specified by:
getAllMappedin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Type Parameters:
RETTYPE- Return type to which is mapped- Parameters:
aFilter- The filter to be applied. May benull.aMapper- The mapper to be invoked. May not benull.- Returns:
- The list all matching and mapped elements. Never
null.
-
findAllMapped
@IsLocked(READ) public final <RETTYPE> void findAllMapped(@Nullable Predicate<? super INTERFACETYPE> aFilter, @Nonnull Function<? super INTERFACETYPE,? extends RETTYPE> aMapper, @Nonnull Consumer<? super RETTYPE> aConsumer)
Description copied from interface:IMapBasedDAOFind all contained items that match the filter, map them to a different type and invoke the consumer on all mapped items.- Specified by:
findAllMappedin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Type Parameters:
RETTYPE- Return type to which is mapped- Parameters:
aFilter- The filter to be applied. May benull.aMapper- The mapper to be invoked. May not benull.aConsumer- The consumer to be invoked for all matches. May not benull.
-
findFirst
@IsLocked(READ) @Nullable public final INTERFACETYPE findFirst(@Nullable Predicate<? super INTERFACETYPE> aFilter)
Description copied from interface:IMapBasedDAOFind the the first element that matches the filter.- Specified by:
findFirstin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
- The first matching item or
null.
-
findFirstMapped
@Nullable @IsLocked(READ) public final <RETTYPE> RETTYPE findFirstMapped(@Nullable Predicate<? super INTERFACETYPE> aFilter, @Nonnull Function<? super INTERFACETYPE,? extends RETTYPE> aMapper)
- Specified by:
findFirstMappedin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>
-
isNotEmpty
@IsLocked(READ) public final boolean isNotEmpty()
- Specified by:
isNotEmptyin interfacecom.helger.commons.lang.IHasSize
-
containsAny
@IsLocked(READ) public final boolean containsAny(@Nullable Predicate<? super INTERFACETYPE> aFilter)
- Specified by:
containsAnyin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
trueif at least one item matches the filter
-
isEmpty
@IsLocked(READ) public final boolean isEmpty()
- Specified by:
isEmptyin interfacecom.helger.commons.lang.IHasSize
-
containsNone
@IsLocked(READ) public final boolean containsNone(@Nullable Predicate<? super INTERFACETYPE> aFilter)
- Specified by:
containsNonein interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
trueif no item matches the filter
-
containsOnly
@IsLocked(READ) public final boolean containsOnly(@Nullable Predicate<? super INTERFACETYPE> aFilter)
- Specified by:
containsOnlyin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
trueif all items match the filter
-
forEach
@IsLocked(READ) public final void forEach(@Nullable BiConsumer<? super String,? super INTERFACETYPE> aConsumer)
Description copied from interface:IMapBasedDAOIterate each entry- Specified by:
forEachin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aConsumer- Consumer to use. May benull.
-
forEach
@IsLocked(READ) public final void forEach(@Nullable BiPredicate<? super String,? super INTERFACETYPE> aFilter, @Nullable BiConsumer<? super String,? super INTERFACETYPE> aConsumer)
Description copied from interface:IMapBasedDAOIterate each entry- Specified by:
forEachin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- Optional filter to limit the entries for which the consumer is called. May benull.aConsumer- Consumer to use. May benull.
-
forEachKey
@IsLocked(READ) public final void forEachKey(@Nullable Consumer<? super String> aConsumer)
Description copied from interface:IMapBasedDAOIterate each key- Specified by:
forEachKeyin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aConsumer- Consumer to use. May benull.
-
forEachKey
@IsLocked(READ) public final void forEachKey(@Nullable Predicate<? super String> aFilter, @Nullable Consumer<? super String> aConsumer)
Description copied from interface:IMapBasedDAOIterate each key- Specified by:
forEachKeyin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- Optional filter to limit the entries for which the consumer is called. May benull.aConsumer- Consumer to use. May benull.
-
forEachValue
@IsLocked(READ) public final void forEachValue(@Nullable Consumer<? super INTERFACETYPE> aConsumer)
Description copied from interface:IMapBasedDAOIterate each value- Specified by:
forEachValuein interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aConsumer- Consumer to use. May benull.
-
internalForEachValue
@IsLocked(READ) protected final void internalForEachValue(@Nullable Consumer<? super IMPLTYPE> aConsumer)
-
forEachValue
@IsLocked(READ) public final void forEachValue(@Nullable Predicate<? super INTERFACETYPE> aFilter, @Nullable Consumer<? super INTERFACETYPE> aConsumer)
Description copied from interface:IMapBasedDAOIterate each value- Specified by:
forEachValuein interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- Optional filter to limit the entries for which the consumer is called. May benull.aConsumer- Consumer to use. May benull.
-
internalForEachValue
@IsLocked(READ) protected final void internalForEachValue(@Nullable Predicate<? super IMPLTYPE> aFilter, @Nullable Consumer<? super IMPLTYPE> aConsumer)
-
internalGetOfID
@Nullable @MustBeLocked(READ) protected final IMPLTYPE internalGetOfID(@Nullable String sID)
Same asgetOfID(String)but the locking must happen on the called side.- Parameters:
sID- The ID to search. May benull.- Returns:
nullif no such item exists- Since:
- 9.1.5
-
getOfID
@Nullable @IsLocked(READ) protected final IMPLTYPE getOfID(@Nullable String sID)
Find the element with the provided ID. Locking is done internally.- Parameters:
sID- The ID to search. May benull.- Returns:
nullif no such item exists
-
getAtIndex
@Nullable @IsLocked(READ) protected final INTERFACETYPE getAtIndex(@Nonnegative int nIndex)
Get the item at the specified index. This method only returns defined results if an ordered map is used for data storage.- Parameters:
nIndex- The index to retrieve. Should be ≥ 0.- Returns:
nullif an invalid index was provided.
-
internalContainsWithID
@MustBeLocked(READ) protected final boolean internalContainsWithID(@Nullable String sID)
-
containsWithID
@IsLocked(READ) public final boolean containsWithID(@Nullable String sID)
- Specified by:
containsWithIDin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
sID- The ID to be checked. May benull.- Returns:
trueif an item with the provided ID is contained.
-
containsAllIDs
@IsLocked(READ) public final boolean containsAllIDs(@Nullable Iterable<String> aIDs)
Description copied from interface:IMapBasedDAOCheck if all IDs are contained- Specified by:
containsAllIDsin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aIDs- IDs to check- Returns:
trueif all IDs are contained
-
getAllIDs
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsSet<String> getAllIDs()
- Specified by:
getAllIDsin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Returns:
- A set with the IDs of all contained items. Never
nullbut maybe empty.
-
size
@Nonnegative public final int size()
- Specified by:
sizein interfacecom.helger.commons.lang.IHasSize
-
getCount
@Nonnegative public final int getCount(@Nullable Predicate<? super INTERFACETYPE> aFilter)
- Specified by:
getCountin interfaceIMapBasedDAO<INTERFACETYPE extends com.helger.commons.id.IHasID<String>>- Parameters:
aFilter- The filter to be applied. May benull.- Returns:
- The number of items matching the provided filter. Always ≥ 0.
-
toString
public String toString()
- Overrides:
toStringin classAbstractWALDAO<IMPLTYPE extends INTERFACETYPE>
-
-