Class EntityEditEvents

java.lang.Object
is.codion.framework.model.EntityEditEvents

public final class EntityEditEvents extends Object
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 Type
    Method
    Description
    static void
    addDeleteConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
    Adds a delete consumer, notified each time entities of the given type are deleted.
    static void
    addInsertConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
    Adds an insert consumer, notified each time entities of the given type are inserted.
    static void
    addUpdateConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.Entity>> consumer)
    Adds an update consumer, notified each time entities of the given type are updated.
    static void
    notifyDeleted(Collection<is.codion.framework.domain.entity.Entity> deletedEntities)
    Notifies delete
    static void
    notifyInserted(Collection<is.codion.framework.domain.entity.Entity> insertedEntities)
    Notifies insert
    static void
    notifyUpdated(Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.Entity> updatedEntities)
    Notifies update
    static void
    removeDeleteConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
    Removes the given consumer
    static void
    removeInsertConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
    Removes the given consumer
    static void
    removeUpdateConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.Entity>> consumer)
    Removes the given consumer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • addInsertConsumer

      public static void addInsertConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
      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 for
      consumer - the consumer
    • addUpdateConsumer

      public static void addUpdateConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.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 for
      consumer - the consumer
    • addDeleteConsumer

      public static void addDeleteConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
      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 for
      consumer - the consumer
    • removeInsertConsumer

      public static void removeInsertConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
      Removes the given consumer
      Parameters:
      entityType - the entityType
      consumer - the consumer to remove
    • removeUpdateConsumer

      public static void removeUpdateConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.Entity>> consumer)
      Removes the given consumer
      Parameters:
      entityType - the entityType
      consumer - the consumer to remove
    • removeDeleteConsumer

      public static void removeDeleteConsumer(is.codion.framework.domain.entity.EntityType entityType, Consumer<Collection<is.codion.framework.domain.entity.Entity>> consumer)
      Removes the given consumer
      Parameters:
      entityType - the entityType
      consumer - the consumer to remove
    • notifyInserted

      public static void notifyInserted(Collection<is.codion.framework.domain.entity.Entity> insertedEntities)
      Notifies insert
      Parameters:
      insertedEntities - the inserted entities
    • notifyUpdated

      public static void notifyUpdated(Map<is.codion.framework.domain.entity.Entity.Key,is.codion.framework.domain.entity.Entity> updatedEntities)
      Notifies update
      Parameters:
      updatedEntities - the updated entities mapped to their original primary key
    • notifyDeleted

      public static void notifyDeleted(Collection<is.codion.framework.domain.entity.Entity> deletedEntities)
      Notifies delete
      Parameters:
      deletedEntities - the deleted entities