Class AutoTimestampEntityEventListener

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

@Singleton public class AutoTimestampEntityEventListener extends AutoPopulatedEntityEventListener implements io.micronaut.data.model.runtime.PropertyAutoPopulator<io.micronaut.data.annotation.DateUpdated>
An event listener that handles DateCreated and DateUpdated.
Since:
2.3.0
  • Constructor Details

    • AutoTimestampEntityEventListener

      public AutoTimestampEntityEventListener(DateTimeProvider<?> dateTimeProvider, DataConversionService conversionService)
      Default constructor.
      Parameters:
      dateTimeProvider - The date time provider
      conversionService - The conversion service
  • 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>
    • preUpdate

      public boolean preUpdate(@NonNull @NonNull io.micronaut.data.event.EntityEventContext<Object> context)
      Specified by:
      preUpdate 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.DateUpdated>