Class DeferredChangeEvent<E>

java.lang.Object
io.micronaut.data.jdbc.notification.DeferredChangeEvent<E>
Type Parameters:
E - The persistent entity type.
All Implemented Interfaces:
ChangeEvent<E>

@Internal public final class DeferredChangeEvent<E> extends Object implements ChangeEvent<E>
Internal change event whose entity state is materialized by listener AOP advice immediately before listener invocation.

A failed materialization is not cached, allowing outer retry advice to invoke the loader again. A successful result, including a null result, is cached so a later listener failure can be retried without reloading the entity.

  • Constructor Details

    • DeferredChangeEvent

      public DeferredChangeEvent(ChangeOperation operation, @Nullable ChangeEventMetadata metadata, Supplier<@Nullable E> entityLoader)
      Creates a deferred event.
      Parameters:
      operation - The reported operation.
      metadata - Provider-specific event metadata.
      entityLoader - The entity loader invoked by the listener interceptor.
  • Method Details

    • operation

      public ChangeOperation operation()
      Description copied from interface: ChangeEvent
      Returns the operation reported by the notification provider.
      Specified by:
      operation in interface ChangeEvent<E>
      Returns:
      The reported change operation.
    • entity

      public Optional<E> entity()
      Description copied from interface: ChangeEvent
      Returns the entity state associated with this event, when it is available.
      Specified by:
      entity in interface ChangeEvent<E>
      Returns:
      The entity, or empty when the provider has no entity state for this event.
    • metadata

      public <M extends ChangeEventMetadata> Optional<M> metadata(Class<M> metadataType)
      Description copied from interface: ChangeEvent
      Finds provider-specific metadata of the requested type.
      Specified by:
      metadata in interface ChangeEvent<E>
      Type Parameters:
      M - The metadata type.
      Parameters:
      metadataType - The metadata type.
      Returns:
      The metadata when this event contains the requested type.