java.lang.Object
is.codion.framework.model.EntityEditEvents
A central event hub for listening for entity inserts, updates and deletes.
You must keep a live reference to any listeners added in order to prevent
them from being garbage collected, since listeners are added via a
WeakReference
.
EntityEditModel
uses this to post its events.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addDeleteConsumer
(EntityType entityType, Consumer<Collection<Entity>> consumer) Adds a delete consumer, notified each time entities of the given type are deleted.static void
addInsertConsumer
(EntityType entityType, Consumer<Collection<Entity>> consumer) Adds an insert consumer, notified each time entities of the given type are inserted.static void
addUpdateConsumer
(EntityType entityType, Consumer<Map<Entity.Key, Entity>> consumer) Adds an update consumer, notified each time entities of the given type are updated.static void
notifyDeleted
(Collection<Entity> deletedEntities) Notifies deletestatic void
notifyInserted
(Collection<Entity> insertedEntities) Notifies insertstatic void
notifyUpdated
(Map<Entity.Key, Entity> updatedEntities) Notifies updatestatic void
removeDeleteConsumer
(EntityType entityType, Consumer<Collection<Entity>> consumer) Removes the given consumerstatic void
removeInsertConsumer
(EntityType entityType, Consumer<Collection<Entity>> consumer) Removes the given consumerstatic void
removeUpdateConsumer
(EntityType entityType, Consumer<Map<Entity.Key, Entity>> consumer) Removes the given consumer
-
Method Details
-
addInsertConsumer
Adds an insert consumer, notified each time entities of the given type are inserted. Note that you have to keep a live reference to the consumer instance, otherwise it will be garbage collected, due to a weak reference.- Parameters:
entityType
- the type of entity to listen forconsumer
- the consumer
-
addUpdateConsumer
public static void addUpdateConsumer(EntityType entityType, Consumer<Map<Entity.Key, Entity>> consumer) Adds an update consumer, notified each time entities of the given type are updated. Note that you have to keep a live reference to the consumer instance, otherwise it will be garbage collected, due to a weak reference.- Parameters:
entityType
- the type of entity to listen forconsumer
- the consumer
-
addDeleteConsumer
Adds a delete consumer, notified each time entities of the given type are deleted. Note that you have to keep a live reference to the consumer instance, otherwise it will be garbage collected, due to a weak reference.- Parameters:
entityType
- the type of entity to listen forconsumer
- the consumer
-
removeInsertConsumer
public static void removeInsertConsumer(EntityType entityType, Consumer<Collection<Entity>> consumer) Removes the given consumer- Parameters:
entityType
- the entityTypeconsumer
- the consumer to remove
-
removeUpdateConsumer
public static void removeUpdateConsumer(EntityType entityType, Consumer<Map<Entity.Key, Entity>> consumer) Removes the given consumer- Parameters:
entityType
- the entityTypeconsumer
- the consumer to remove
-
removeDeleteConsumer
public static void removeDeleteConsumer(EntityType entityType, Consumer<Collection<Entity>> consumer) Removes the given consumer- Parameters:
entityType
- the entityTypeconsumer
- the consumer to remove
-
notifyInserted
Notifies insert- Parameters:
insertedEntities
- the inserted entities
-
notifyUpdated
Notifies update- Parameters:
updatedEntities
- the updated entities mapped to their original primary key
-
notifyDeleted
Notifies delete- Parameters:
deletedEntities
- the deleted entities
-