Class TenantIdEntityEventListener

java.lang.Object
io.micronaut.data.runtime.event.listeners.AutoPopulatedEntityEventListener
io.micronaut.data.runtime.event.listeners.TenantIdEntityEventListener
All Implemented Interfaces:
io.micronaut.core.order.Ordered, io.micronaut.data.event.EntityEventListener<Object>, io.micronaut.data.model.runtime.PropertyAutoPopulator<io.micronaut.data.annotation.TenantId>, EventListener

@Requires(beans=TenantResolver.class) @Singleton public class TenantIdEntityEventListener extends AutoPopulatedEntityEventListener implements io.micronaut.data.model.runtime.PropertyAutoPopulator<io.micronaut.data.annotation.TenantId>
An event listener that handles TenantId.
Since:
4.8.0
  • Constructor Details

    • TenantIdEntityEventListener

      public TenantIdEntityEventListener(TenantResolver tenantResolver, DataConversionService conversionService)
      Default constructor.
      Parameters:
      conversionService - The conversion service
      tenantResolver - The tenant resolver
  • Method Details

    • getEventTypes

      @NonNull protected @NonNull List<Class<? extends Annotation>> getEventTypes()
      Specified by:
      getEventTypes in class AutoPopulatedEntityEventListener
      Returns:
      The event type
    • getPropertyPredicate

      @NonNull protected @NonNull Predicate<io.micronaut.data.model.runtime.RuntimePersistentProperty<Object>> getPropertyPredicate()
      Specified by:
      getPropertyPredicate in class AutoPopulatedEntityEventListener
      Returns:
      A predicate to apply for the given property.
    • prePersist

      public boolean prePersist(@NonNull @NonNull io.micronaut.data.event.EntityEventContext<Object> context)
      Specified by:
      prePersist in interface io.micronaut.data.event.EntityEventListener<Object>
    • populate

      @NonNull public @NonNull Object populate(io.micronaut.data.model.runtime.RuntimePersistentProperty<?> property, @Nullable @Nullable Object previousValue)
      Specified by:
      populate in interface io.micronaut.data.model.runtime.PropertyAutoPopulator<io.micronaut.data.annotation.TenantId>