Class AbstractGenericDepot<T extends IPNDItem>
- Direct Known Subclasses:
AbstractNodeDepot, AbstractResourceDepot
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanAdds a single item.getItems()protected voidloadItemsDirect(List<T> source) Bulk-loads items from a source list that is guaranteed to be duplicate-free (e.g., the output of a previousgetItems()call).abstract voidprotected voidpostAddOnCopy(T item) Called byloadItemsDirect(List)once per item.booleanbooleanprotected voidCalled once at the very start ofloadItemsDirect(List), before any items are loaded and before anypostAddOnCopy(T)calls.voidReplaces all current items with the provided list.
-
Constructor Details
-
AbstractGenericDepot
-
-
Method Details
-
getDepotId
-
resetDerivedState
protected void resetDerivedState()Called once at the very start ofloadItemsDirect(List), before any items are loaded and before anypostAddOnCopy(T)calls.Override in subclasses that maintain derived boolean flags (e.g.
isZeroLoad,hasFlexibleLoads,hasTimedLoads). The override must reset those flags to their "empty-depot" values so that the subsequentpostAddOnCopy(T)loop can build them up correctly from scratch.Default is a no-op.
-
loadItemsDirect
Bulk-loads items from a source list that is guaranteed to be duplicate-free (e.g., the output of a previousgetItems()call).Calls
resetDerivedState()first so that subclass flags are always consistent with the new contents, then populates both backing structures and callspostAddOnCopy(T)per item.DO NOT call from user-facing mutators. Use
add(T)there — it has the duplicate-safety contract. This method is only correct whensourceis guaranteed unique.- Parameters:
source- duplicate-free list of items to load; must not benull, must not containnullelements
-
postAddOnCopy
Called byloadItemsDirect(List)once per item. Default is a no-op.Override in subclasses that maintain derived state which must stay in sync even during a copy. Keep the implementation cheap — this is on the hot copy path.
- Parameters:
item- the item just added to the backing structures
-
setItems
Replaces all current items with the provided list.Delegates to
loadItemsDirect(List): the caller-supplied list is treated as a known-clean replacement set, so the full merge/dupe-check pipeline inadd(T)is skipped. This is safe becausesetItemsis itself a full replacement (not an incremental mutation), and any prior state is discarded first.resetDerivedState()is called insideloadItemsDirectbefore the loop. -
getItems
-
add
Adds a single item. Performs a full duplicate-id check and merge if needed. Use this for all user-facing mutations. For bulk-loading a copy, useloadItemsDirect(List)instead. -
mergeItem
-
postAdd
-
add
-
remove
-
replace
-
get
-