diff --git a/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java b/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java index 4602ef22c..adc098922 100644 --- a/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java @@ -27,6 +27,7 @@ import org.springframework.data.repository.Repository; * and uses Project Reactor types which are built on top of Reactive Streams. * * @author Mark Paluch + * @author Christph Strobl * @since 2.0 * @see Mono * @see Flux @@ -39,7 +40,8 @@ public interface ReactiveCrudRepository extends Repository { * entity instance completely. * * @param entity must not be {@literal null}. - * @return the saved entity. + * @return {@link Mono} emitting the saved entity. + * @throws IllegalArgumentException in case the given {@code entity} is {@literal null}. */ Mono save(S entity); @@ -47,8 +49,8 @@ public interface ReactiveCrudRepository extends Repository { * Saves all given entities. * * @param entities must not be {@literal null}. - * @return the saved entities. - * @throws IllegalArgumentException in case the given entity is {@literal null}. + * @return {@link Flux} emitting the saved entities. + * @throws IllegalArgumentException in case the given {@link Iterable} {@code entities} is {@literal null}. */ Flux saveAll(Iterable entities); @@ -56,8 +58,8 @@ public interface ReactiveCrudRepository extends Repository { * Saves all given entities. * * @param entityStream must not be {@literal null}. - * @return the saved entities. - * @throws IllegalArgumentException in case the given {@code Publisher} is {@literal null}. + * @return {@link Flux} emitting the saved entities. + * @throws IllegalArgumentException in case the given {@code Publisher} {@code entityStream} is {@literal null}. */ Flux saveAll(Publisher entityStream); @@ -65,66 +67,68 @@ public interface ReactiveCrudRepository extends Repository { * Retrieves an entity by its id. * * @param id must not be {@literal null}. - * @return the entity with the given id or {@link Mono#empty()} if none found. - * @throws IllegalArgumentException if {@code id} is {@literal null}. + * @return {@link Mono} emitting the entity with the given id or {@link Mono#empty()} if none found. + * @throws IllegalArgumentException in case the given {@code id} is {@literal null}. */ Mono findById(ID id); /** - * Retrieves an entity by its id supplied by a {@link Mono}. + * Retrieves an entity by its id supplied by a {@link Publisher}. * * @param id must not be {@literal null}. Uses the first emitted element to perform the find-query. - * @return the entity with the given id or {@link Mono#empty()} if none found. - * @throws IllegalArgumentException if {@code id} is {@literal null}. + * @return {@link Mono} emitting the entity with the given id or {@link Mono#empty()} if none found. + * @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}. */ Mono findById(Publisher id); /** - * Returns whether an entity with the given id exists. + * Returns whether an entity with the id exists. * * @param id must not be {@literal null}. - * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. - * @throws IllegalArgumentException if {@code id} is {@literal null}. + * @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise. + * @throws IllegalArgumentException in case the given {@code id} is {@literal null}. */ Mono existsById(ID id); /** - * Returns whether an entity with the given id, supplied by a {@link Mono}, exists. Uses the first emitted element to - * perform the exists-query. + * Returns whether an entity with the given id, supplied by a {@link Publisher}, exists. Uses the first emitted + * element to perform the exists-query. * * @param id must not be {@literal null}. - * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise + * @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}. */ Mono existsById(Publisher id); /** * Returns all instances of the type. * - * @return all entities. + * @return {@link Flux} emitting all entities. */ Flux findAll(); /** - * Returns all instances of the type with the given IDs. + * Returns all instances with the given IDs. * * @param ids must not be {@literal null}. - * @return the found entities. + * @return {@link Flux} emitting the found entities. + * @throws IllegalArgumentException in case the given {@link Iterable} {@code ids} is {@literal null}. */ Flux findAllById(Iterable ids); /** - * Returns all instances of the type with the given IDs. + * Returns all instances of the type with the given IDs supplied by a {@link Publisher}. * * @param idStream must not be {@literal null}. - * @return the found entities. + * @return {@link Flux} emitting the found entities. + * @throws IllegalArgumentException in case the given {@link Publisher} {@code idStream} is {@literal null}. */ Flux findAllById(Publisher idStream); /** * Returns the number of entities available. * - * @return the number of entities. + * @return {@link Mono} emitting the number of entities. */ Mono count(); @@ -132,14 +136,25 @@ public interface ReactiveCrudRepository extends Repository { * Deletes the entity with the given id. * * @param id must not be {@literal null}. + * @return {@link Mono} signaling when operation has completed. * @throws IllegalArgumentException in case the given {@code id} is {@literal null}. */ Mono deleteById(ID id); + /** + * Deletes the entity with the given id supplied by a {@link Publisher}. + * + * @param id must not be {@literal null}. + * @return {@link Mono} signaling when operation has completed. + * @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}. + */ + Mono deleteById(Publisher id); + /** * Deletes a given entity. * * @param entity must not be {@literal null}. + * @return {@link Mono} signaling when operation has completed. * @throws IllegalArgumentException in case the given entity is {@literal null}. */ Mono delete(T entity); @@ -148,20 +163,24 @@ public interface ReactiveCrudRepository extends Repository { * Deletes the given entities. * * @param entities must not be {@literal null}. - * @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}. + * @return {@link Mono} signaling when operation has completed. + * @throws IllegalArgumentException in case the given {@link Iterable} {@code entities} is {@literal null}. */ Mono deleteAll(Iterable entities); /** - * Deletes the given entities. + * Deletes the given entities supplied by a {@link Publisher}. * * @param entityStream must not be {@literal null}. - * @throws IllegalArgumentException in case the given {@link Publisher} is {@literal null}. + * @return {@link Mono} signaling when operation has completed. + * @throws IllegalArgumentException in case the given {@link Publisher} {@code entityStream} is {@literal null}. */ Mono deleteAll(Publisher entityStream); /** * Deletes all entities managed by the repository. + * + * @return {@link Mono} signaling when operation has completed. */ Mono deleteAll(); } diff --git a/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java b/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java index 3a496c8d7..113d2f5e1 100644 --- a/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java @@ -26,6 +26,7 @@ import org.springframework.data.repository.NoRepositoryBean; * abstraction. * * @author Mark Paluch + * @author Christoph Strobl * @since 2.0 * @see Sort * @see Mono @@ -39,6 +40,7 @@ public interface ReactiveSortingRepository extends ReactiveCrudRepository * * @param sort must not be {@literal null}. * @return all entities sorted by the given options. + * @throws IllegalArgumentException in case the given {@link Sort} is {@literal null}. */ Flux findAll(Sort sort); }