Interface RxJava3CrudRepository<T,ID>
- All Superinterfaces:
Repository<T,
ID>
- All Known Subinterfaces:
RxJava3SortingRepository<T,
ID>
Interface for generic CRUD operations on a repository for a specific type. This repository follows reactive paradigms
and uses RxJava 3 types.
- Since:
- 2.4
- Author:
- Mark Paluch
- See Also:
-
Maybe
Single
Flowable
Completable
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single<Long>
count()
Returns the number of entities available.io.reactivex.rxjava3.core.Completable
Deletes a given entity.io.reactivex.rxjava3.core.Completable
Deletes all entities managed by the repository.io.reactivex.rxjava3.core.Completable
Deletes the given entities supplied by aFlowable
.io.reactivex.rxjava3.core.Completable
Deletes the given entities.io.reactivex.rxjava3.core.Completable
deleteAllById
(Iterable<? extends ID> ids) Deletes all instances of the typeT
with the given IDs.io.reactivex.rxjava3.core.Completable
deleteById
(ID id) Deletes the entity with the given id.io.reactivex.rxjava3.core.Single<Boolean>
existsById
(ID id) Returns whether an entity with the given id exists.io.reactivex.rxjava3.core.Single<Boolean>
existsById
(io.reactivex.rxjava3.core.Single<ID> id) Returns whether an entity with the given id, supplied by aSingle
, exists.io.reactivex.rxjava3.core.Flowable<T>
findAll()
Returns all instances of the type.io.reactivex.rxjava3.core.Flowable<T>
findAllById
(io.reactivex.rxjava3.core.Flowable<ID> idStream) Returns all instances of the typeT
with the given IDs supplied by aFlowable
.io.reactivex.rxjava3.core.Flowable<T>
findAllById
(Iterable<ID> ids) Returns all instances of the typeT
with the given IDs.io.reactivex.rxjava3.core.Maybe<T>
Retrieves an entity by its id.io.reactivex.rxjava3.core.Maybe<T>
Retrieves an entity by its id supplied by aSingle
.<S extends T>
io.reactivex.rxjava3.core.Single<S>save
(S entity) Saves a given entity.<S extends T>
io.reactivex.rxjava3.core.Flowable<S>saveAll
(io.reactivex.rxjava3.core.Flowable<S> entityStream) Saves all given entities.<S extends T>
io.reactivex.rxjava3.core.Flowable<S>Saves all given entities.
-
Method Details
-
save
Saves a given entity. Use the returned instance for further operations as the save operation might have changed the entity instance completely.- Parameters:
entity
- must not be null.- Returns:
Single
emitting the saved entity.- Throws:
IllegalArgumentException
- in case the given entity is null.
-
saveAll
Saves all given entities.- Parameters:
entities
- must not be null.- Returns:
Flowable
emitting the saved entities.- Throws:
IllegalArgumentException
- in case the givenentities
or one of its entities is null.
-
saveAll
<S extends T> io.reactivex.rxjava3.core.Flowable<S> saveAll(io.reactivex.rxjava3.core.Flowable<S> entityStream) Saves all given entities.- Parameters:
entityStream
- must not be null.- Returns:
Flowable
emitting the saved entities.- Throws:
IllegalArgumentException
- in case the givenentityStream
is null.
-
findById
Retrieves an entity by its id.- Parameters:
id
- must not be null.- Returns:
Maybe
emitting the entity with the given id orMaybe.empty()
if none found.- Throws:
IllegalArgumentException
- in case the given id is null.
-
findById
Retrieves an entity by its id supplied by aSingle
.- Parameters:
id
- must not be null. Uses the first emitted element to perform the find-query.- Returns:
Maybe
emitting the entity with the given id orMaybe.empty()
if none found.- Throws:
IllegalArgumentException
- in case the givenid
is null.
-
existsById
Returns whether an entity with the given id exists.- Parameters:
id
- must not be null.- Returns:
Single
emitting true if an entity with the given id exists, false otherwise.- Throws:
IllegalArgumentException
- in case the given id is null.
-
existsById
Returns whether an entity with the given id, supplied by aSingle
, exists.- Parameters:
id
- must not be null.- Returns:
Single
emitting true if an entity with the given id exists, false otherwise.- Throws:
IllegalArgumentException
- in case the givenid
is null.
-
findAll
io.reactivex.rxjava3.core.Flowable<T> findAll()Returns all instances of the type.- Returns:
Flowable
emitting all entities.
-
findAllById
Returns all instances of the typeT
with the given IDs.If some or all ids are not found, no entities are returned for these IDs.
Note that the order of elements in the result is not guaranteed.
- Parameters:
ids
- must not be null nor contain any null values.- Returns:
Flowable
emitting the found entities. The size can be equal or less than the number of given ids.- Throws:
IllegalArgumentException
- in case the givenids
or one of its items is null.
-
findAllById
Returns all instances of the typeT
with the given IDs supplied by aFlowable
.If some or all ids are not found, no entities are returned for these IDs.
Note that the order of elements in the result is not guaranteed.
- Parameters:
idStream
- must not be null.- Returns:
Flowable
emitting the found entities.- Throws:
IllegalArgumentException
- in case the givenidStream
is null.
-
count
io.reactivex.rxjava3.core.Single<Long> count()Returns the number of entities available.- Returns:
Single
emitting the number of entities.
-
deleteById
Deletes the entity with the given id.- Parameters:
id
- must not be null.- Returns:
Completable
signaling when operation has completed.- Throws:
IllegalArgumentException
- in case the given id is null.
-
delete
Deletes a given entity.- Parameters:
entity
- must not be null.- Returns:
Completable
signaling when operation has completed.- Throws:
IllegalArgumentException
- in case the given entity is null.
-
deleteAllById
Deletes all instances of the typeT
with the given IDs.- Parameters:
ids
- must not be null.- Returns:
Completable
signaling when operation has completed.- Throws:
IllegalArgumentException
- in case the given ids or one of its elements is null. null.- Since:
- 2.5
-
deleteAll
Deletes the given entities.- Parameters:
entities
- must not be null.- Returns:
Completable
signaling when operation has completed.- Throws:
IllegalArgumentException
- in case the givenentities
or one of its entities is null.
-
deleteAll
io.reactivex.rxjava3.core.Completable deleteAll(io.reactivex.rxjava3.core.Flowable<? extends T> entityStream) Deletes the given entities supplied by aFlowable
.- Parameters:
entityStream
- must not be null.- Returns:
Completable
signaling when operation has completed.- Throws:
IllegalArgumentException
- in case the givenentityStream
is null.
-
deleteAll
io.reactivex.rxjava3.core.Completable deleteAll()Deletes all entities managed by the repository.- Returns:
Completable
signaling when operation has completed.
-