Class DefaultActionQueue
java.lang.Object
io.github.blyznytsiaorg.bibernate.actionqueue.impl.DefaultActionQueue
- All Implemented Interfaces:
ActionQueue
Default implementation of the
ActionQueue
interface.
Manages and executes entity actions categorized by their types, including insert, update, and delete operations.
This class ensures proper handling of interdependencies between different types of actions during execution.- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Map
<ActionType, Set<EntityAction>> A map that categorizes entity actions based on their types (INSERT, UPDATE, DELETE).private boolean
Flag indicating whether the action queue has been executed. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
addDeleteAction
(EntityAction deleteEntityAction) Adds a DELETE type entity action to the entity actions map, taking into account interdependencies with INSERT and UPDATE type actions.void
addEntityAction
(EntityAction entityAction) Adds an entity action to the corresponding type category in the entity actions map.private void
addInsertAction
(EntityAction insertEntityAction) Adds an INSERT type entity action to the entity actions map, taking into account interdependencies with UPDATE and DELETE type actions.private void
addUpdateAction
(EntityAction updateEntityAction) Adds an UPDATE type entity action to the entity actions map, taking into account interdependencies with INSERT and DELETE type actions.private void
executeDeleteEntityAction
(Set<EntityAction> deleteEntityActions) Executes DELETE type entity actions.void
Executes entity actions in the order of INSERT, UPDATE, and DELETE types.private <T extends Collection<?>>
voidexecuteIfNotEmpty
(Consumer<T> consumer, T collections) Executes a consumer on a collection if the collection is not empty.private void
executeInsertEntityAction
(Set<EntityAction> insertEntityActions) Executes INSERT type entity actions.private void
executeUpdateEntityAction
(Set<EntityAction> updateEntityActions) Executes UPDATE type entity actions.private void
Initializes the entity actions map to ensure each type category has an associated set.boolean
Checks if the action queue is set to not execute actions.
-
Field Details
-
entityActions
A map that categorizes entity actions based on their types (INSERT, UPDATE, DELETE). -
isExecuted
private boolean isExecutedFlag indicating whether the action queue has been executed. When 'true', it signifies that the action queue should not perform any execution of entity actions, providing control over the processing flow.
-
-
Constructor Details
-
DefaultActionQueue
public DefaultActionQueue()
-
-
Method Details
-
executeEntityAction
public void executeEntityAction()Executes entity actions in the order of INSERT, UPDATE, and DELETE types. Clears the entity actions map after execution.- Specified by:
executeEntityAction
in interfaceActionQueue
-
addEntityAction
Adds an entity action to the corresponding type category in the entity actions map.- Specified by:
addEntityAction
in interfaceActionQueue
- Parameters:
entityAction
- The entity action to be added.
-
isNotExecuted
public boolean isNotExecuted()Checks if the action queue is set to not execute actions. When this method returns true, it indicates that the action queue is in a state where it should not perform any execution of entity actions.- Specified by:
isNotExecuted
in interfaceActionQueue
- Returns:
- true if the action queue is set to not execute actions, false otherwise.
-
initEntityActions
private void initEntityActions()Initializes the entity actions map to ensure each type category has an associated set. -
addInsertAction
Adds an INSERT type entity action to the entity actions map, taking into account interdependencies with UPDATE and DELETE type actions.- Parameters:
insertEntityAction
- The INSERT type entity action to be added.
-
addUpdateAction
Adds an UPDATE type entity action to the entity actions map, taking into account interdependencies with INSERT and DELETE type actions.- Parameters:
updateEntityAction
- The UPDATE type entity action to be added.
-
addDeleteAction
Adds a DELETE type entity action to the entity actions map, taking into account interdependencies with INSERT and UPDATE type actions.- Parameters:
deleteEntityAction
- The DELETE type entity action to be added.
-
executeInsertEntityAction
Executes INSERT type entity actions.- Parameters:
insertEntityActions
- The set of INSERT type entity actions to be executed.
-
executeUpdateEntityAction
Executes UPDATE type entity actions.- Parameters:
updateEntityActions
- The set of UPDATE type entity actions to be executed.
-
executeDeleteEntityAction
Executes DELETE type entity actions.- Parameters:
deleteEntityActions
- The set of DELETE type entity actions to be executed.
-
executeIfNotEmpty
Executes a consumer on a collection if the collection is not empty.- Type Parameters:
T
- The type of the collection.- Parameters:
consumer
- The consumer to be executed.collections
- The collection to be checked and passed to the consumer if not empty.
-