Skip to content

DATACMNS-1601 - Improving the JavaDoc of the CrudRepository. #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.3.0.BUILD-SNAPSHOT</version>
<version>2.3.0.DATACMNS-1601-SNAPSHOT</version>

<name>Spring Data Core</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,26 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
*
* @param entity must not be {@literal null}.
* @return the saved entity; will never be {@literal null}.
* @throws IllegalArgumentException in case the given {@code entity} is {@literal null}.
*/
<S extends T> S save(S entity);

/**
* Saves all given entities.
*
* @param entities must not be {@literal null}.
* @return the saved entities; will never be {@literal null}.
* @throws IllegalArgumentException in case the given entity is {@literal null}.
* @param entities must not be {@literal null} nor must it contain {@literal null}.
* @return the saved entities; will never be {@literal null}. The returned {@literal Iterable} will have the same size
* as the {@literal Iterable} passed as an argument.
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
* {@literal null}.
*/
<S extends T> Iterable<S> saveAll(Iterable<S> entities);

/**
* Retrieves an entity by its id.
*
* @param id must not be {@literal null}.
* @return the entity with the given id or {@literal Optional#empty()} if none found
* @return the entity with the given id or {@literal Optional#empty()} if none found.
* @throws IllegalArgumentException if {@code id} is {@literal null}.
*/
Optional<T> findById(ID id);
Expand All @@ -70,17 +73,22 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
Iterable<T> findAll();

/**
* Returns all instances of the type with the given IDs.
* Returns all instances of the type {@code T} with the given IDs.
* <p>
* If some or all ids are not found, no entities are returned for these IDs.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param ids
* @return
* @param ids must not be {@literal null} nor contain any {@literal null} values.
* @return guaranteed to be not {@literal null}. The size can be equal or less than the number of given {@code ids}.
* @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}.
*/
Iterable<T> findAllById(Iterable<ID> ids);

/**
* Returns the number of entities available.
*
* @return the number of entities
* @return the number of entities.
*/
long count();

Expand All @@ -95,16 +103,16 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
/**
* Deletes a given entity.
*
* @param entity
* @param entity must not be {@literal null}.
* @throws IllegalArgumentException in case the given entity is {@literal null}.
*/
void delete(T entity);

/**
* Deletes the given entities.
*
* @param entities
* @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}.
* @param entities must not be {@literal null}. Must not contain {@literal null} elements.
* @throws IllegalArgumentException in case the given {@literal entities} or one of its entities is {@literal null}.
*/
void deleteAll(Iterable<? extends T> entities);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @param entities must not be {@literal null}.
* @return {@link Flux} emitting the saved entities.
* @throws IllegalArgumentException in case the given {@link Iterable} {@code entities} is {@literal null}.
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
* {@literal null}.
*/
<S extends T> Flux<S> saveAll(Iterable<S> entities);

Expand All @@ -59,7 +60,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @param entityStream must not be {@literal null}.
* @return {@link Flux} emitting the saved entities.
* @throws IllegalArgumentException in case the given {@code Publisher} {@code entityStream} is {@literal null}.
* @throws IllegalArgumentException in case the given {@link Publisher entityStream} is {@literal null}.
*/
<S extends T> Flux<S> saveAll(Publisher<S> entityStream);

Expand All @@ -77,12 +78,12 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @param id must not be {@literal null}. Uses the first emitted element to perform the find-query.
* @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}.
* @throws IllegalArgumentException in case the given {@link Publisher id} is {@literal null}.
*/
Mono<T> findById(Publisher<ID> id);

/**
* Returns whether an entity with the id exists.
* Returns whether an entity with the given {@code id} exists.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns whether an entity with the given {@code id} exists.
* Returns whether an entity with the given {@literal id} exists.

*
* @param id must not be {@literal null}.
* @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise.
Expand All @@ -95,8 +96,8 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
* element to perform the exists-query.
*
* @param id must not be {@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}.
* @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 id} is {@literal null}.
*/
Mono<Boolean> existsById(Publisher<ID> id);

Expand All @@ -108,20 +109,29 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
Flux<T> findAll();

/**
* Returns all instances with the given IDs.
* Returns all instances of the type {@code T} with the given IDs.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns all instances of the type {@code T} with the given IDs.
* Returns all instances of the type {@literal T} with the given IDs.

* <p>
* If some or all ids are not found, no entities are returned for these IDs.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param ids must not be {@literal null}.
* @return {@link Flux} emitting the found entities.
* @throws IllegalArgumentException in case the given {@link Iterable} {@code ids} is {@literal null}.
* @param ids must not be {@literal null} nor contain any {@literal null} values.
* @return {@link Flux} emitting the found entities. The size can be equal or less than the number of given
* {@code ids}.
* @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}.
*/
Flux<T> findAllById(Iterable<ID> ids);

/**
* Returns all instances of the type with the given IDs supplied by a {@link Publisher}.
* Returns all instances of the type {@code T} with the given IDs supplied by a {@link Publisher}.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns all instances of the type {@code T} with the given IDs supplied by a {@link Publisher}.
* Returns all instances of the type {@literal T} with the given IDs supplied by a {@link Publisher}.

* <p>
* If some or all ids are not found, no entities are returned for these IDs.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param idStream must not be {@literal null}.
* @return {@link Flux} emitting the found entities.
* @throws IllegalArgumentException in case the given {@link Publisher} {@code idStream} is {@literal null}.
* @throws IllegalArgumentException in case the given {@link Publisher idStream} is {@literal null}.
*/
Flux<T> findAllById(Publisher<ID> idStream);

Expand All @@ -146,7 +156,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @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}.
* @throws IllegalArgumentException in case the given {@link Publisher id} is {@literal null}.
*/
Mono<Void> deleteById(Publisher<ID> id);

Expand All @@ -164,7 +174,8 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @param entities must not be {@literal null}.
* @return {@link Mono} signaling when operation has completed.
* @throws IllegalArgumentException in case the given {@link Iterable} {@code entities} is {@literal null}.
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
* {@literal null}.
*/
Mono<Void> deleteAll(Iterable<? extends T> entities);

Expand All @@ -173,7 +184,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
*
* @param entityStream must not be {@literal null}.
* @return {@link Mono} signaling when operation has completed.
* @throws IllegalArgumentException in case the given {@link Publisher} {@code entityStream} is {@literal null}.
* @throws IllegalArgumentException in case the given {@link Publisher entityStream} is {@literal null}.
*/
Mono<Void> deleteAll(Publisher<? extends T> entityStream);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,98 +42,112 @@ public interface RxJava2CrudRepository<T, ID> extends Repository<T, ID> {
* entity instance completely.
*
* @param entity must not be {@literal null}.
* @return the saved entity.
* @return {@link Single} emitting the saved entity.
* @throws IllegalArgumentException in case the given {@code entity} is {@literal null}.
*/
<S extends T> Single<S> save(S entity);

/**
* 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 Flowable} emitting the saved entities.
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
* {@literal null}.
*/
<S extends T> Flowable<S> saveAll(Iterable<S> entities);

/**
* 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 Flowable} emitting the saved entities.
* @throws IllegalArgumentException in case the given {@link Flowable entityStream} is {@literal null}.
*/
<S extends T> Flowable<S> saveAll(Flowable<S> entityStream);

/**
* Retrieves an entity by its id.
*
* @param id must not be {@literal null}.
* @return the entity with the given id or {@link Maybe#empty()} if none found.
* @throws IllegalArgumentException if {@code id} is {@literal null}.
* @return {@link Maybe} emitting the entity with the given id or {@link Maybe#empty()} if none found.
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
*/
Maybe<T> findById(ID id);

/**
* Retrieves an entity by its id supplied by a {@link Single}.
*
* @param id must not be {@literal null}.
* @return the entity with the given id or {@link Maybe#empty()} if none found.
* @throws IllegalArgumentException if {@code id} is {@literal null}.
* @param id must not be {@literal null}. Uses the first emitted element to perform the find-query.
* @return {@link Maybe} emitting the entity with the given id or {@link Maybe#empty()} if none found.
* @throws IllegalArgumentException in case the given {@link Single id} is {@literal null}.
*/
Maybe<T> findById(Single<ID> id);

/**
* Returns whether an entity with the given id exists.
* Returns whether an entity with the given {@code id} exists.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns whether an entity with the given {@code id} exists.
* Returns whether an entity with the given {@literal id} exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm stopping commenting on this, since it is easier to find and fix within the IDE.

*
* @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 Single} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it now gets really nitpicky but shouldn't it be TRUE since it is the constant from the wrapper type, not the primitive?

If you agree there are more places like this.

* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}.

*/
Single<Boolean> existsById(ID id);

/**
* Returns whether an entity with the given id, supplied by a {@link Single}, 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 Single} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise.
* @throws IllegalArgumentException in case the given {@link Single id} is {@literal null}.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be either {@literal IllegalArgument} or {@link IllegalArgument}

Same in many other places.

*/
Single<Boolean> existsById(Single<ID> id);

/**
* Returns all instances of the type.
*
* @return all entities.
* @return {@link Flowable} emitting all entities.
*/
Flowable<T> findAll();

/**
* Returns all instances of the type with the given IDs.
* Returns all instances of the type {@code T} with the given IDs.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are mixing IDs and ids and I think it should be {@literal ids} referring to the parameter name.

* <p>
* If some or all ids are not found, no entities are returned for these IDs.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param ids must not be {@literal null}.
* @return the found entities.
* @param ids must not be {@literal null} nor contain any {@literal null} values.
* @return {@link Flowable} emitting the found entities. The size can be equal or less than the number of given
* {@code ids}.
* @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}.
*/
Flowable<T> findAllById(Iterable<ID> ids);

/**
* Returns all instances of the type with the given IDs.
* Returns all instances of the type {@code T} with the given IDs supplied by a {@link Flowable}.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

* <p>
* If some or all ids are not found, no entities are returned for these IDs.
* <p>
* Note that the order of elements in the result is not guaranteed.
*
* @param idStream must not be {@literal null}.
* @return the found entities.
* @return {@link Flowable} emitting the found entities.
* @throws IllegalArgumentException in case the given {@link Flowable idStream} is {@literal null}.
*/
Flowable<T> findAllById(Flowable<ID> idStream);

/**
* Returns the number of entities available.
*
* @return the number of entities.
* @return {@link Single} emitting the number of entities.
*/
Single<Long> count();

/**
* Deletes the entity with the given id.
*
* @param id must not be {@literal null}.
* @return {@link Completable} signaling when operation has completed.
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
*/
Completable deleteById(ID id);
Expand All @@ -142,6 +156,7 @@ public interface RxJava2CrudRepository<T, ID> extends Repository<T, ID> {
* Deletes a given entity.
*
* @param entity must not be {@literal null}.
* @return {@link Completable} signaling when operation has completed.
* @throws IllegalArgumentException in case the given entity is {@literal null}.
*/
Completable delete(T entity);
Expand All @@ -150,20 +165,25 @@ public interface RxJava2CrudRepository<T, ID> extends Repository<T, ID> {
* Deletes the given entities.
*
* @param entities must not be {@literal null}.
* @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}.
* @return {@link Completable} signaling when operation has completed.
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
* {@literal null}.
*/
Completable deleteAll(Iterable<? extends T> entities);

/**
* Deletes the given entities.
* Deletes the given entities supplied by a {@link Flowable}.
*
* @param entityStream must not be {@literal null}.
* @throws IllegalArgumentException in case the given {@link Flowable} is {@literal null}.
* @return {@link Completable} signaling when operation has completed.
* @throws IllegalArgumentException in case the given {@link Flowable entityStream} is {@literal null}.
*/
Completable deleteAll(Flowable<? extends T> entityStream);

/**
* Deletes all entities managed by the repository.
*
* @return {@link Completable} signaling when operation has completed.
*/
Completable deleteAll();
}