Skip to content

Commit 01ce3e0

Browse files
schaudermp911de
authored andcommitted
DATACMNS-1601 - Improving the JavaDoc of the CrudRepository.
Clarifying expectations and guarantees or lack thereof. Original pull request: #412.
1 parent 796baa3 commit 01ce3e0

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

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

+17-8
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
3838
/**
3939
* Saves all given entities.
4040
*
41-
* @param entities must not be {@literal null}.
42-
* @return the saved entities; will never be {@literal null}.
43-
* @throws IllegalArgumentException in case the given entity is {@literal null}.
41+
* @param entities must not be {@literal null} nor must it contain {@literal null}
42+
* @return the saved entities; will never be {@literal null}. The returned {@literal Iterable} will have the same size
43+
* 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+
* {@literal null}.
4446
*/
4547
<S extends T> Iterable<S> saveAll(Iterable<S> entities);
4648

@@ -71,9 +73,15 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
7173

7274
/**
7375
* Returns all instances of the type with the given IDs.
76+
* <p>
77+
* If some or all ids are not found no entities are returned for these IDs.
78+
* <p>
79+
* Note that the order of elements in the result is not guaranteed.
7480
*
75-
* @param ids
76-
* @return
81+
* @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}.
7785
*/
7886
Iterable<T> findAllById(Iterable<ID> ids);
7987

@@ -95,16 +103,17 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
95103
/**
96104
* Deletes a given entity.
97105
*
98-
* @param entity
106+
* @param entity must not be {@literal null}.
99107
* @throws IllegalArgumentException in case the given entity is {@literal null}.
100108
*/
101109
void delete(T entity);
102110

103111
/**
104112
* Deletes the given entities.
105113
*
106-
* @param entities
107-
* @throws IllegalArgumentException in case the given {@link Iterable} is {@literal null}.
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}.
108117
*/
109118
void deleteAll(Iterable<? extends T> entities);
110119

0 commit comments

Comments
 (0)