From 3099125aa3feba209eab832cb9dce58f10abc31a Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 8 Feb 2017 10:44:01 +0100 Subject: [PATCH] DATACMNS-988 - Polishing. Improve JavaDoc. Remove findAll declarations in reactive sorting repositories as they are inherited with the same signature. Original Pull Request: #194 --- .../reactive/ReactiveCrudRepository.java | 44 ++++++++--------- .../reactive/ReactiveSortingRepository.java | 28 ++--------- .../reactive/RxJava1CrudRepository.java | 49 +++++++++---------- .../reactive/RxJava1SortingRepository.java | 27 ++-------- 4 files changed, 52 insertions(+), 96 deletions(-) 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 f1af95c4e..8601a0e68 100644 --- a/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ public interface ReactiveCrudRepository extends Repo * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the * entity instance completely. * - * @param entity - * @return the saved entity + * @param entity must not be {@literal null}. + * @return the saved entity. */ Mono save(S entity); @@ -49,7 +49,7 @@ public interface ReactiveCrudRepository extends Repo * Saves all given entities. * * @param entities must not be {@literal null}. - * @return the saved entities + * @return the saved entities. * @throws IllegalArgumentException in case the given entity is {@literal null}. */ Flux save(Iterable entities); @@ -58,7 +58,7 @@ public interface ReactiveCrudRepository extends Repo * Saves all given entities. * * @param entityStream must not be {@literal null}. - * @return the saved entities + * @return the saved entities. * @throws IllegalArgumentException in case the given {@code Publisher} is {@literal null}. */ Flux save(Publisher entityStream); @@ -67,8 +67,8 @@ public interface ReactiveCrudRepository extends Repo * Retrieves an entity by its id. * * @param id must not be {@literal null}. - * @return the entity with the given id or {@literal null} if none found - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return the entity with the given id or {@link Mono#empty()} if none found. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Mono findOne(ID id); @@ -76,8 +76,8 @@ public interface ReactiveCrudRepository extends Repo * Retrieves an entity by its id supplied by a {@link Mono}. * * @param id must not be {@literal null}. - * @return the entity with the given id or {@literal null} if none found - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return the entity with the given id or {@link Mono#empty()} if none found. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Mono findOne(Mono id); @@ -85,8 +85,8 @@ public interface ReactiveCrudRepository extends Repo * Returns whether an entity with the given id exists. * * @param id must not be {@literal null}. - * @return true if an entity with the given id exists, {@literal false} otherwise - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Mono exists(ID id); @@ -94,7 +94,7 @@ public interface ReactiveCrudRepository extends Repo * Returns whether an entity with the given id exists supplied by a {@link Mono}. * * @param id must not be {@literal null}. - * @return true if an entity with the given id exists, {@literal false} otherwise + * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise * @throws IllegalArgumentException if {@code id} is {@literal null} */ Mono exists(Mono id); @@ -102,30 +102,30 @@ public interface ReactiveCrudRepository extends Repo /** * Returns all instances of the type. * - * @return all entities + * @return all entities. */ Flux findAll(); /** * Returns all instances of the type with the given IDs. * - * @param ids - * @return + * @param ids must not be {@literal null}. + * @return the found entities. */ Flux findAll(Iterable ids); /** * Returns all instances of the type with the given IDs. * - * @param idStream - * @return + * @param idStream must not be {@literal null}. + * @return the found entities. */ Flux findAll(Publisher idStream); /** * Returns the number of entities available. * - * @return the number of entities + * @return the number of entities. */ Mono count(); @@ -133,14 +133,14 @@ public interface ReactiveCrudRepository extends Repo * Deletes the entity with the given id. * * @param id must not be {@literal null}. - * @throws IllegalArgumentException in case the given {@code id} is {@literal null} + * @throws IllegalArgumentException in case the given {@code id} is {@literal null}. */ Mono delete(ID id); /** * Deletes a given entity. * - * @param entity + * @param entity must not be {@literal null}. * @throws IllegalArgumentException in case the given entity is {@literal null}. */ Mono delete(T entity); @@ -148,7 +148,7 @@ public interface ReactiveCrudRepository extends Repo /** * Deletes the given entities. * - * @param entities + * @param entities must not be {@literal null}. * @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}. */ Mono delete(Iterable entities); @@ -156,7 +156,7 @@ public interface ReactiveCrudRepository extends Repo /** * Deletes the given entities. * - * @param entityStream + * @param entityStream must not be {@literal null}. * @throws IllegalArgumentException in case the given {@link Publisher} is {@literal null}. */ Mono delete(Publisher entityStream); 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 40476c6ac..0151e92e2 100644 --- a/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/ReactiveSortingRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.data.repository.reactive; import java.io.Serializable; -import org.reactivestreams.Publisher; import org.springframework.data.domain.Sort; import org.springframework.data.repository.NoRepositoryBean; @@ -37,32 +36,11 @@ import reactor.core.publisher.Mono; @NoRepositoryBean public interface ReactiveSortingRepository extends ReactiveCrudRepository { - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll() - */ - @Override - Flux findAll(); - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll(java.lang.Iterable) - */ - @Override - Flux findAll(Iterable ids); - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll(org.reactivestreams.Publisher) - */ - @Override - Flux findAll(Publisher idStream); - /** * Returns all entities sorted by the given options. * - * @param sort - * @return all entities sorted by the given options + * @param sort must not be {@literal null}. + * @return all entities sorted by the given options. */ Flux findAll(Sort sort); } diff --git a/src/main/java/org/springframework/data/repository/reactive/RxJava1CrudRepository.java b/src/main/java/org/springframework/data/repository/reactive/RxJava1CrudRepository.java index d551a430a..21551f318 100644 --- a/src/main/java/org/springframework/data/repository/reactive/RxJava1CrudRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/RxJava1CrudRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.data.repository.reactive; import java.io.Serializable; -import org.reactivestreams.Publisher; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.Repository; @@ -41,8 +40,8 @@ public interface RxJava1CrudRepository extends Repos * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the * entity instance completely. * - * @param entity - * @return the saved entity + * @param entity must not be {@literal null}. + * @return the saved entity. */ Single save(S entity); @@ -50,7 +49,7 @@ public interface RxJava1CrudRepository extends Repos * Saves all given entities. * * @param entities must not be {@literal null}. - * @return the saved entities + * @return the saved entities. * @throws IllegalArgumentException in case the given entity is {@literal null}. */ Observable save(Iterable entities); @@ -59,7 +58,7 @@ public interface RxJava1CrudRepository extends Repos * Saves all given entities. * * @param entityStream must not be {@literal null}. - * @return the saved entities + * @return the saved entities. * @throws IllegalArgumentException in case the given {@code Publisher} is {@literal null}. */ Observable save(Observable entityStream); @@ -68,8 +67,8 @@ public interface RxJava1CrudRepository extends Repos * Retrieves an entity by its id. * * @param id must not be {@literal null}. - * @return the entity with the given id or {@literal null} if none found - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return the entity with the given id or {@link Observable#empty()} if none found. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Observable findOne(ID id); @@ -77,8 +76,8 @@ public interface RxJava1CrudRepository extends Repos * 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 {@literal null} if none found - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return the entity with the given id or {@link Observable#empty()} if none found. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Observable findOne(Single id); @@ -86,8 +85,8 @@ public interface RxJava1CrudRepository extends Repos * Returns whether an entity with the given id exists. * * @param id must not be {@literal null}. - * @return true if an entity with the given id exists, {@literal false} otherwise - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Single exists(ID id); @@ -95,38 +94,38 @@ public interface RxJava1CrudRepository extends Repos * Returns whether an entity with the given id exists supplied by a {@link Single}. * * @param id must not be {@literal null}. - * @return true if an entity with the given id exists, {@literal false} otherwise - * @throws IllegalArgumentException if {@code id} is {@literal null} + * @return {@literal true} if an entity with the given id exists, {@literal false} otherwise. + * @throws IllegalArgumentException if {@code id} is {@literal null}. */ Single exists(Single id); /** * Returns all instances of the type. * - * @return all entities + * @return all entities. */ Observable findAll(); /** * Returns all instances of the type with the given IDs. * - * @param ids - * @return + * @param ids must not be {@literal null}. + * @return the found entities. */ Observable findAll(Iterable ids); /** * Returns all instances of the type with the given IDs. * - * @param idStream - * @return + * @param idStream must not be {@literal null}. + * @return the found entities. */ Observable findAll(Observable idStream); /** * Returns the number of entities available. * - * @return the number of entities + * @return the number of entities. */ Single count(); @@ -134,14 +133,14 @@ public interface RxJava1CrudRepository extends Repos * Deletes the entity with the given id. * * @param id must not be {@literal null}. - * @throws IllegalArgumentException in case the given {@code id} is {@literal null} + * @throws IllegalArgumentException in case the given {@code id} is {@literal null}. */ Completable delete(ID id); /** * Deletes a given entity. * - * @param entity + * @param entity must not be {@literal null}. * @throws IllegalArgumentException in case the given entity is {@literal null}. */ Completable delete(T entity); @@ -149,7 +148,7 @@ public interface RxJava1CrudRepository extends Repos /** * Deletes the given entities. * - * @param entities + * @param entities must not be {@literal null}. * @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}. */ Completable delete(Iterable entities); @@ -157,8 +156,8 @@ public interface RxJava1CrudRepository extends Repos /** * Deletes the given entities. * - * @param entityStream - * @throws IllegalArgumentException in case the given {@link Publisher} is {@literal null}. + * @param entityStream must not be {@literal null}. + * @throws IllegalArgumentException in case the given {@link Observable} is {@literal null}. */ Completable delete(Observable entityStream); diff --git a/src/main/java/org/springframework/data/repository/reactive/RxJava1SortingRepository.java b/src/main/java/org/springframework/data/repository/reactive/RxJava1SortingRepository.java index c09064396..7f5ffaa96 100644 --- a/src/main/java/org/springframework/data/repository/reactive/RxJava1SortingRepository.java +++ b/src/main/java/org/springframework/data/repository/reactive/RxJava1SortingRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,32 +37,11 @@ import rx.Single; @NoRepositoryBean public interface RxJava1SortingRepository extends RxJava1CrudRepository { - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll() - */ - @Override - Observable findAll(); - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll(java.lang.Iterable) - */ - @Override - Observable findAll(Iterable ids); - - /* - * (non-Javadoc) - * @see org.springframework.data.repository.reactive.ReactiveCrudRepository#findAll(org.reactivestreams.Publisher) - */ - @Override - Observable findAll(Observable idStream); - /** * Returns all entities sorted by the given options. * - * @param sort - * @return all entities sorted by the given options + * @param sort must not be {@literal null}. + * @return all entities sorted by the given options. */ Observable findAll(Sort sort); }