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
-
Field Summary
Fields inherited from interface Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionReactiveValidatingEntityCallback(jakarta.validation.Validator validator) Creates a newReactiveValidatingEntityCallbackusing the givenValidator. -
Method Summary
Modifier and TypeMethodDescriptionintgetOrder()onBeforeSave(Object entity, org.bson.Document document, String collection) Entity callback method invoked before a domain object is saved.voidsetOrder(int order) Specify the order value for thisReactiveValidatingEntityCallback.
-
Constructor Details
-
ReactiveValidatingEntityCallback
public ReactiveValidatingEntityCallback(jakarta.validation.Validator validator) Creates a newReactiveValidatingEntityCallbackusing the givenValidator.- Parameters:
validator- must not be null.
-
-
Method Details
-
getOrder
-
setOrder
public void setOrder(int order) Specify the order value for thisReactiveValidatingEntityCallback.The default value is
100.- Since:
- 5.0
- See Also:
-
onBeforeSave
Description copied from interface:ReactiveBeforeSaveCallbackEntity callback method invoked before a domain object is saved. Can return either the same or a modified instance of the domain object and can modifyDocumentcontents. This method is called after converting theentitytoDocumentso effectively the document is used as outcome of invoking this callback.- Specified by:
onBeforeSavein interfaceReactiveBeforeSaveCallback<Object>- Parameters:
entity- the domain object to save.document-Documentrepresenting theentity.collection- name of the collection.- Returns:
- a
Publisheremitting the domain object to be persisted.
-