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,EntityEventListener<Object>,PropertyAutoPopulator<DateUpdated>,EventListener
@Singleton
public class AutoTimestampEntityEventListener
extends AutoPopulatedEntityEventListener
implements PropertyAutoPopulator<DateUpdated>
An event listener that handles
DateCreated and DateUpdated.- Since:
- 2.3.0
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.data.event.EntityEventListener
NOOPFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionAutoTimestampEntityEventListener(DateTimeProvider<?> dateTimeProvider, DataConversionService conversionService) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull List<Class<? extends Annotation>>protected @NonNull Predicate<RuntimePersistentProperty<Object>>@NonNull Objectpopulate(RuntimePersistentProperty<?> property, @Nullable Object previousValue) Auto-populating the property.booleanprePersist(@NonNull EntityEventContext<Object> context) A pre-persist hook.booleanpreUpdate(@NonNull EntityEventContext<Object> context) A pre-update hook.Methods inherited from class io.micronaut.data.runtime.event.listeners.AutoPopulatedEntityEventListener
getApplicableProperties, supportsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.data.event.EntityEventListener
postLoad, postPersist, postRemove, postUpdate, preQuery, preRemoveMethods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Constructor Details
-
AutoTimestampEntityEventListener
public AutoTimestampEntityEventListener(DateTimeProvider<?> dateTimeProvider, DataConversionService conversionService) Default constructor.- Parameters:
dateTimeProvider- The date time providerconversionService- The conversion service
-
-
Method Details
-
getEventTypes
- Specified by:
getEventTypesin classAutoPopulatedEntityEventListener- Returns:
- The event type
-
getPropertyPredicate
- Specified by:
getPropertyPredicatein classAutoPopulatedEntityEventListener- Returns:
- A predicate to apply for the given property.
-
prePersist
Description copied from interface:EntityEventListenerA pre-persist hook. Implementors can return false to evict the operation.- Specified by:
prePersistin interfaceEntityEventListener<Object>- Parameters:
context- The context object- Returns:
- A boolean value indicating whether to proceed with the operation.
-
preUpdate
Description copied from interface:EntityEventListenerA pre-update hook. Implementors can return false to evict the operation.- Specified by:
preUpdatein interfaceEntityEventListener<Object>- Parameters:
context- The context object- Returns:
- A boolean value indicating whether to proceed with the operation.
-
populate
@NonNull public @NonNull Object populate(RuntimePersistentProperty<?> property, @Nullable @Nullable Object previousValue) Description copied from interface:PropertyAutoPopulatorAuto-populating the property.- Specified by:
populatein interfacePropertyAutoPopulator<DateUpdated>- Parameters:
property- the property to auto-populatepreviousValue- the previous value, if any- Returns:
- new value
-