Skip to content

Commit 95fcc2d

Browse files
committed
DATACMNS-1601 - Polishing.
Document throws on save(…). Align documentation for reactive repositories. Original pull request: #412.
1 parent f78d49e commit 95fcc2d

File tree

3 files changed

+91
-60
lines changed

3 files changed

+91
-60
lines changed

src/main/java/org/springframework/data/repository/CrudRepository.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
3232
*
3333
* @param entity must not be {@literal null}.
3434
* @return the saved entity; will never be {@literal null}.
35+
* @throws IllegalArgumentException in case the given {@literal entity} is {@literal null}.
3536
*/
3637
<S extends T> S save(S entity);
3738

3839
/**
3940
* Saves all given entities.
4041
*
41-
* @param entities must not be {@literal null} nor must it contain {@literal null}
42+
* @param entities must not be {@literal null} nor must it contain {@literal null}.
4243
* @return the saved entities; will never be {@literal null}. The returned {@literal Iterable} will have the same size
4344
* as the {@literal Iterable} passed as an argument.
44-
* @throws IllegalArgumentException in case the given {@literal Iterable} or one of its contained entities is
45+
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
4546
* {@literal null}.
4647
*/
4748
<S extends T> Iterable<S> saveAll(Iterable<S> entities);
@@ -50,8 +51,8 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
5051
* Retrieves an entity by its id.
5152
*
5253
* @param id must not be {@literal null}.
53-
* @return the entity with the given id or {@literal Optional#empty()} if none found
54-
* @throws IllegalArgumentException if {@code id} is {@literal null}.
54+
* @return the entity with the given id or {@literal Optional#empty()} if none found.
55+
* @throws IllegalArgumentException if {@literal id} is {@literal null}.
5556
*/
5657
Optional<T> findById(ID id);
5758

@@ -60,7 +61,7 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
6061
*
6162
* @param id must not be {@literal null}.
6263
* @return {@literal true} if an entity with the given id exists, {@literal false} otherwise.
63-
* @throws IllegalArgumentException if {@code id} is {@literal null}.
64+
* @throws IllegalArgumentException if {@literal id} is {@literal null}.
6465
*/
6566
boolean existsById(ID id);
6667

@@ -72,31 +73,31 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
7273
Iterable<T> findAll();
7374

7475
/**
75-
* Returns all instances of the type with the given IDs.
76+
* Returns all instances of the type {@code T} with the given IDs.
7677
* <p>
77-
* If some or all ids are not found no entities are returned for these IDs.
78+
* If some or all ids are not found, no entities are returned for these IDs.
7879
* <p>
7980
* Note that the order of elements in the result is not guaranteed.
8081
*
8182
* @param ids must not be {@literal null} nor contain any {@literal null} values.
82-
* @return guaranteed to be not {@literal null}. The size will be equal or smaller than that of the argument.
83-
* @throws IllegalArgumentException in case the given {@literal Iterable} or one of its contained entities is
84-
* {@literal null}.
83+
* @return guaranteed to be not {@literal null}. The size can be equal or less than the number of given
84+
* {@literal ids}.
85+
* @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}.
8586
*/
8687
Iterable<T> findAllById(Iterable<ID> ids);
8788

8889
/**
8990
* Returns the number of entities available.
9091
*
91-
* @return the number of entities
92+
* @return the number of entities.
9293
*/
9394
long count();
9495

9596
/**
9697
* Deletes the entity with the given id.
9798
*
9899
* @param id must not be {@literal null}.
99-
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}
100+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
100101
*/
101102
void deleteById(ID id);
102103

@@ -111,9 +112,8 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
111112
/**
112113
* Deletes the given entities.
113114
*
114-
* @param entities must not be {@literal null}. Must not contain {@literal null} elements
115-
* @throws IllegalArgumentException in case the given {@literal Iterable} or one of its contained entities is
116-
* {@literal null}.
115+
* @param entities must not be {@literal null}. Must not contain {@literal null} elements.
116+
* @throws IllegalArgumentException in case the given {@literal entities} or one of its entities is {@literal null}.
117117
*/
118118
void deleteAll(Iterable<? extends T> entities);
119119

src/main/java/org/springframework/data/repository/reactive/ReactiveCrudRepository.java

+30-19
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
4141
*
4242
* @param entity must not be {@literal null}.
4343
* @return {@link Mono} emitting the saved entity.
44-
* @throws IllegalArgumentException in case the given {@code entity} is {@literal null}.
44+
* @throws IllegalArgumentException in case the given {@literal entity} is {@literal null}.
4545
*/
4646
<S extends T> Mono<S> save(S entity);
4747

@@ -50,7 +50,8 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
5050
*
5151
* @param entities must not be {@literal null}.
5252
* @return {@link Flux} emitting the saved entities.
53-
* @throws IllegalArgumentException in case the given {@link Iterable} {@code entities} is {@literal null}.
53+
* @throws IllegalArgumentException in case the given {@link Iterable entities} or one of its entities is
54+
* {@literal null}.
5455
*/
5556
<S extends T> Flux<S> saveAll(Iterable<S> entities);
5657

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

@@ -68,7 +69,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
6869
*
6970
* @param id must not be {@literal null}.
7071
* @return {@link Mono} emitting the entity with the given id or {@link Mono#empty()} if none found.
71-
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
72+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}.
7273
*/
7374
Mono<T> findById(ID id);
7475

@@ -77,16 +78,16 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
7778
*
7879
* @param id must not be {@literal null}. Uses the first emitted element to perform the find-query.
7980
* @return {@link Mono} emitting the entity with the given id or {@link Mono#empty()} if none found.
80-
* @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}.
81+
* @throws IllegalArgumentException in case the given {@link Publisher id} is {@literal null}.
8182
*/
8283
Mono<T> findById(Publisher<ID> id);
8384

8485
/**
85-
* Returns whether an entity with the id exists.
86+
* Returns whether an entity with the given {@literal id} exists.
8687
*
8788
* @param id must not be {@literal null}.
8889
* @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise.
89-
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
90+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}.
9091
*/
9192
Mono<Boolean> existsById(ID id);
9293

@@ -95,8 +96,8 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
9596
* element to perform the exists-query.
9697
*
9798
* @param id must not be {@literal null}.
98-
* @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise
99-
* @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}.
99+
* @return {@link Mono} emitting {@literal true} if an entity with the given id exists, {@literal false} otherwise.
100+
* @throws IllegalArgumentException in case the given {@link Publisher id} is {@literal null}.
100101
*/
101102
Mono<Boolean> existsById(Publisher<ID> id);
102103

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

110111
/**
111-
* Returns all instances with the given IDs.
112+
* Returns all instances of the type {@code T} with the given IDs.
113+
* <p>
114+
* If some or all ids are not found, no entities are returned for these IDs.
115+
* <p>
116+
* Note that the order of elements in the result is not guaranteed.
112117
*
113-
* @param ids must not be {@literal null}.
114-
* @return {@link Flux} emitting the found entities.
115-
* @throws IllegalArgumentException in case the given {@link Iterable} {@code ids} is {@literal null}.
118+
* @param ids must not be {@literal null} nor contain any {@literal null} values.
119+
* @return {@link Flux} emitting the found entities. The size can be equal or less than the number of given
120+
* {@literal ids}.
121+
* @throws IllegalArgumentException in case the given {@link Iterable ids} or one of its items is {@literal null}.
116122
*/
117123
Flux<T> findAllById(Iterable<ID> ids);
118124

119125
/**
120-
* Returns all instances of the type with the given IDs supplied by a {@link Publisher}.
126+
* Returns all instances of the type {@code T} with the given IDs supplied by a {@link Publisher}.
127+
* <p>
128+
* If some or all ids are not found, no entities are returned for these IDs.
129+
* <p>
130+
* Note that the order of elements in the result is not guaranteed.
121131
*
122132
* @param idStream must not be {@literal null}.
123133
* @return {@link Flux} emitting the found entities.
124-
* @throws IllegalArgumentException in case the given {@link Publisher} {@code idStream} is {@literal null}.
134+
* @throws IllegalArgumentException in case the given {@link Publisher idStream} is {@literal null}.
125135
*/
126136
Flux<T> findAllById(Publisher<ID> idStream);
127137

@@ -137,7 +147,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
137147
*
138148
* @param id must not be {@literal null}.
139149
* @return {@link Mono} signaling when operation has completed.
140-
* @throws IllegalArgumentException in case the given {@code id} is {@literal null}.
150+
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}.
141151
*/
142152
Mono<Void> deleteById(ID id);
143153

@@ -146,7 +156,7 @@ public interface ReactiveCrudRepository<T, ID> extends Repository<T, ID> {
146156
*
147157
* @param id must not be {@literal null}.
148158
* @return {@link Mono} signaling when operation has completed.
149-
* @throws IllegalArgumentException in case the given {@link Publisher} {@code id} is {@literal null}.
159+
* @throws IllegalArgumentException in case the given {@link Publisher id} is {@literal null}.
150160
*/
151161
Mono<Void> deleteById(Publisher<ID> id);
152162

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

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

0 commit comments

Comments
 (0)