30
30
import org .springframework .util .Assert ;
31
31
32
32
/**
33
+ * Simple {@link KeyValueRepository} implementation.
34
+ *
33
35
* @author Christoph Strobl
34
36
* @author Oliver Gierke
35
37
* @author Mark Paluch
@@ -58,38 +60,9 @@ public SimpleKeyValueRepository(EntityInformation<T, ID> metadata, KeyValueOpera
58
60
this .operations = operations ;
59
61
}
60
62
61
- /*
62
- * (non-Javadoc)
63
- * @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Sort)
64
- */
65
- @ Override
66
- public Iterable <T > findAll (Sort sort ) {
67
-
68
- Assert .notNull (sort , "Sort must not be null!" );
69
-
70
- return operations .findAll (sort , entityInformation .getJavaType ());
71
- }
72
-
73
- /*
74
- * (non-Javadoc)
75
- * @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Pageable)
76
- */
77
- @ Override
78
- public Page <T > findAll (Pageable pageable ) {
79
-
80
- Assert .notNull (pageable , "Pageable must not be null!" );
81
-
82
- if (pageable .isUnpaged ()) {
83
- List <T > result = findAll ();
84
- return new PageImpl <>(result , Pageable .unpaged (), result .size ());
85
- }
86
-
87
- Iterable <T > content = operations .findInRange (pageable .getOffset (), pageable .getPageSize (), pageable .getSort (),
88
- entityInformation .getJavaType ());
89
-
90
- return new PageImpl <>(IterableConverter .toList (content ), pageable ,
91
- this .operations .count (entityInformation .getJavaType ()));
92
- }
63
+ // -------------------------------------------------------------------------
64
+ // Methods from CrudRepository
65
+ // -------------------------------------------------------------------------
93
66
94
67
/*
95
68
* (non-Javadoc)
@@ -204,6 +177,18 @@ public void delete(T entity) {
204
177
deleteById (entityInformation .getRequiredId (entity ));
205
178
}
206
179
180
+ /*
181
+ * (non-Javadoc)
182
+ * @see org.springframework.data.repository.CrudRepository#deleteAllById(java.lang.Iterable)
183
+ */
184
+ @ Override
185
+ public void deleteAllById (Iterable <? extends ID > ids ) {
186
+
187
+ Assert .notNull (ids , "The given Iterable of Ids must not be null!" );
188
+
189
+ ids .forEach (this ::deleteById );
190
+ }
191
+
207
192
/*
208
193
* (non-Javadoc)
209
194
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Iterable)
@@ -216,20 +201,49 @@ public void deleteAll(Iterable<? extends T> entities) {
216
201
entities .forEach (this ::delete );
217
202
}
218
203
204
+ /*
205
+ * (non-Javadoc)
206
+ * @see org.springframework.data.repository.CrudRepository#deleteAll()
207
+ */
219
208
@ Override
220
- public void deleteAllById (Iterable <? extends ID > ids ) {
209
+ public void deleteAll () {
210
+ operations .delete (entityInformation .getJavaType ());
211
+ }
221
212
222
- Assert .notNull (ids , "The given Iterable of Ids must not be null!" );
213
+ // -------------------------------------------------------------------------
214
+ // Methods from PagingAndSortingRepository
215
+ // -------------------------------------------------------------------------
223
216
224
- ids .forEach (this ::deleteById );
217
+ /*
218
+ * (non-Javadoc)
219
+ * @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Sort)
220
+ */
221
+ @ Override
222
+ public Iterable <T > findAll (Sort sort ) {
223
+
224
+ Assert .notNull (sort , "Sort must not be null!" );
225
+
226
+ return operations .findAll (sort , entityInformation .getJavaType ());
225
227
}
226
228
227
229
/*
228
230
* (non-Javadoc)
229
- * @see org.springframework.data.repository.CrudRepository#deleteAll( )
231
+ * @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Pageable )
230
232
*/
231
233
@ Override
232
- public void deleteAll () {
233
- operations .delete (entityInformation .getJavaType ());
234
+ public Page <T > findAll (Pageable pageable ) {
235
+
236
+ Assert .notNull (pageable , "Pageable must not be null!" );
237
+
238
+ if (pageable .isUnpaged ()) {
239
+ List <T > result = findAll ();
240
+ return new PageImpl <>(result , Pageable .unpaged (), result .size ());
241
+ }
242
+
243
+ Iterable <T > content = operations .findInRange (pageable .getOffset (), pageable .getPageSize (), pageable .getSort (),
244
+ entityInformation .getJavaType ());
245
+
246
+ return new PageImpl <>(IterableConverter .toList (content ), pageable ,
247
+ this .operations .count (entityInformation .getJavaType ()));
234
248
}
235
249
}
0 commit comments