Class ReactiveValidatingEntityCallback

java.lang.Object
org.springframework.data.mongodb.core.mapping.event.ReactiveValidatingEntityCallback
All Implemented Interfaces:
Ordered, EntityCallback<Object>, ReactiveBeforeSaveCallback<Object>

public class ReactiveValidatingEntityCallback extends Object implements ReactiveBeforeSaveCallback<Object>, Ordered
Reactive variant of JSR-303 dependant entities validator.

When it is registered as Spring component its automatically invoked after object to Document conversion and before entities are saved to the database.

Since:
4.5
Author:
Mark Paluch, Rene Felgenträger
  • Constructor Details

    • ReactiveValidatingEntityCallback

      public ReactiveValidatingEntityCallback(jakarta.validation.Validator validator)
      Creates a new ReactiveValidatingEntityCallback using the given Validator.
      Parameters:
      validator - must not be null.
  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface Ordered
    • setOrder

      public void setOrder(int order)
      Specify the order value for this ReactiveValidatingEntityCallback.

      The default value is 100.

      Since:
      5.0
      See Also:
    • onBeforeSave

      public Mono<Object> onBeforeSave(Object entity, org.bson.Document document, String collection)
      Description copied from interface: ReactiveBeforeSaveCallback
      Entity callback method invoked before a domain object is saved. Can return either the same or a modified instance of the domain object and can modify Document contents. This method is called after converting the entity to Document so effectively the document is used as outcome of invoking this callback.
      Specified by:
      onBeforeSave in interface ReactiveBeforeSaveCallback<Object>
      Parameters:
      entity - the domain object to save.
      document - Document representing the entity.
      collection - name of the collection.
      Returns:
      a Publisher emitting the domain object to be persisted.