1616
1717package org .springframework .data .couchbase .repository .support ;
1818
19- import static org .springframework .data .couchbase .repository .support .Util .*;
20-
2119import reactor .core .publisher .Flux ;
2220import reactor .core .publisher .Mono ;
2321
2624import java .util .stream .Collectors ;
2725
2826import org .reactivestreams .Publisher ;
29-
3027import org .springframework .data .couchbase .core .CouchbaseOperations ;
3128import org .springframework .data .couchbase .core .ReactiveCouchbaseOperations ;
3229import org .springframework .data .couchbase .core .query .Query ;
3330import org .springframework .data .couchbase .repository .ReactiveCouchbaseRepository ;
3431import org .springframework .data .couchbase .repository .query .CouchbaseEntityInformation ;
32+ import static org .springframework .data .couchbase .repository .support .Util .hasNonZeroVersionProperty ;
3533import org .springframework .data .domain .Sort ;
3634import org .springframework .data .util .Streamable ;
3735import org .springframework .util .Assert ;
@@ -69,8 +67,8 @@ public class SimpleReactiveCouchbaseRepository<T, ID> implements ReactiveCouchba
6967 * @param entityInformation the Metadata for the entity.
7068 * @param operations the reference to the reactive template used.
7169 */
72- public SimpleReactiveCouchbaseRepository (CouchbaseEntityInformation <T , String > entityInformation ,
73- ReactiveCouchbaseOperations operations ) {
70+ public SimpleReactiveCouchbaseRepository (final CouchbaseEntityInformation <T , String > entityInformation ,
71+ final ReactiveCouchbaseOperations operations ) {
7472 Assert .notNull (operations , "ReactiveCouchbaseOperations must not be null!" );
7573 Assert .notNull (entityInformation , "CouchbaseEntityInformation must not be null!" );
7674
@@ -80,7 +78,7 @@ public SimpleReactiveCouchbaseRepository(CouchbaseEntityInformation<T, String> e
8078
8179 @ SuppressWarnings ("unchecked" )
8280 @ Override
83- public <S extends T > Mono <S > save (S entity ) {
81+ public <S extends T > Mono <S > save (final S entity ) {
8482 Assert .notNull (entity , "Entity must not be null!" );
8583 // if entity has non-null version property, then replace()
8684 if (hasNonZeroVersionProperty (entity , operations .getConverter ())) {
@@ -91,102 +89,115 @@ public <S extends T> Mono<S> save(S entity) {
9189 }
9290
9391 @ Override
94- public Flux <T > findAll (Sort sort ) {
92+ public Flux <T > findAll (final Sort sort ) {
9593 return findAll (new Query ().with (sort ));
9694 }
9795
96+ @ SuppressWarnings ("unchecked" )
9897 @ Override
99- public <S extends T > Flux <S > saveAll (Iterable <S > entities ) {
98+ public <S extends T > Flux <S > saveAll (final Iterable <S > entities ) {
10099 Assert .notNull (entities , "The given Iterable of entities must not be null!" );
101100 return Flux .fromIterable (entities ).flatMap (this ::save );
102101 }
103102
103+ @ SuppressWarnings ("unchecked" )
104104 @ Override
105- public <S extends T > Flux <S > saveAll (Publisher <S > entityStream ) {
105+ public <S extends T > Flux <S > saveAll (final Publisher <S > entityStream ) {
106106 Assert .notNull (entityStream , "The given Iterable of entities must not be null!" );
107107 return Flux .from (entityStream ).flatMap (this ::save );
108108 }
109109
110+ @ SuppressWarnings ("unchecked" )
110111 @ Override
111- public Mono <T > findById (ID id ) {
112+ public Mono <T > findById (final ID id ) {
112113 return operations .findById (entityInformation .getJavaType ()).one (id .toString ());
113114 }
114115
116+ @ SuppressWarnings ("unchecked" )
115117 @ Override
116- public Mono <T > findById (Publisher <ID > publisher ) {
118+ public Mono <T > findById (final Publisher <ID > publisher ) {
117119 Assert .notNull (publisher , "The given Publisher must not be null!" );
118120 return Mono .from (publisher ).flatMap (this ::findById );
119121 }
120122
123+ @ SuppressWarnings ("unchecked" )
121124 @ Override
122- public Mono <Boolean > existsById (ID id ) {
125+ public Mono <Boolean > existsById (final ID id ) {
123126 Assert .notNull (id , "The given id must not be null!" );
124127 return operations .existsById ().one (id .toString ());
125128 }
126129
130+ @ SuppressWarnings ("unchecked" )
127131 @ Override
128- public Mono <Boolean > existsById (Publisher <ID > publisher ) {
132+ public Mono <Boolean > existsById (final Publisher <ID > publisher ) {
129133 Assert .notNull (publisher , "The given Publisher must not be null!" );
130134 return Mono .from (publisher ).flatMap (this ::existsById );
131135 }
132136
137+ @ SuppressWarnings ("unchecked" )
133138 @ Override
134139 public Flux <T > findAll () {
135140 return findAll (new Query ());
136141 }
137142
138143 @ SuppressWarnings ("unchecked" )
139144 @ Override
140- public Flux <T > findAllById (Iterable <ID > ids ) {
145+ public Flux <T > findAllById (final Iterable <ID > ids ) {
141146 Assert .notNull (ids , "The given Iterable of ids must not be null!" );
142147 List <String > convertedIds = Streamable .of (ids ).stream ().map (Objects ::toString ).collect (Collectors .toList ());
143148 return (Flux <T >) operations .findById (entityInformation .getJavaType ()).all (convertedIds );
144149 }
145150
151+ @ SuppressWarnings ("unchecked" )
146152 @ Override
147- public Flux <T > findAllById (Publisher <ID > entityStream ) {
153+ public Flux <T > findAllById (final Publisher <ID > entityStream ) {
148154 Assert .notNull (entityStream , "The given entityStream must not be null!" );
149155 return Flux .from (entityStream ).flatMap (this ::findById );
150156 }
151157
158+ @ SuppressWarnings ("unchecked" )
152159 @ Override
153- public Mono <Void > deleteById (ID id ) {
160+ public Mono <Void > deleteById (final ID id ) {
154161 return operations .removeById ().one (id .toString ()).then ();
155162 }
156163
157164 @ Override
158- public Mono <Void > deleteById (Publisher <ID > publisher ) {
165+ public Mono <Void > deleteById (final Publisher <ID > publisher ) {
159166 Assert .notNull (publisher , "The given id must not be null!" );
160167 return Mono .from (publisher ).flatMap (this ::deleteById );
161168 }
162169
170+ @ SuppressWarnings ("unchecked" )
163171 @ Override
164- public Mono <Void > delete (T entity ) {
172+ public Mono <Void > delete (final T entity ) {
165173 Assert .notNull (entity , "Entity must not be null!" );
166174 return operations .removeById ().one (entityInformation .getId (entity )).then ();
167175 }
168176
177+ @ SuppressWarnings ("unchecked" )
169178 @ Override
170- public Mono <Void > deleteAllById (Iterable <? extends ID > ids ) {
171- return operations .removeById ().all (Streamable .of (ids ).map (Object ::toString ).toList ()).then ();
172- }
173-
174- @ Override
175- public Mono <Void > deleteAll (Iterable <? extends T > entities ) {
179+ public Mono <Void > deleteAll (final Iterable <? extends T > entities ) {
176180 return operations .removeById ().all (Streamable .of (entities ).map (entityInformation ::getId ).toList ()).then ();
177181 }
178182
179183 @ Override
180- public Mono <Void > deleteAll (Publisher <? extends T > entityStream ) {
184+ public Mono <Void > deleteAll (final Publisher <? extends T > entityStream ) {
181185 Assert .notNull (entityStream , "The given publisher of entities must not be null!" );
182186 return Flux .from (entityStream ).flatMap (this ::delete ).single ();
183187 }
184188
189+ @ Override
190+ public Mono <Void > deleteAllById (final Iterable <? extends ID > ids ) {
191+ return operations .removeById ().all (Streamable .of (ids ).map (Object ::toString ).toList ()).then ();
192+ }
193+
194+ @ SuppressWarnings ("unchecked" )
185195 @ Override
186196 public Mono <Long > count () {
187197 return operations .findByQuery (entityInformation .getJavaType ()).consistentWith (buildQueryScanConsistency ()).count ();
188198 }
189199
200+ @ SuppressWarnings ("unchecked" )
190201 @ Override
191202 public Mono <Void > deleteAll () {
192203 return operations .removeByQuery (entityInformation .getJavaType ()).all ().then ();
@@ -201,7 +212,7 @@ protected CouchbaseEntityInformation<T, String> getEntityInformation() {
201212 return entityInformation ;
202213 }
203214
204- private Flux <T > findAll (Query query ) {
215+ private Flux <T > findAll (final Query query ) {
205216 return operations .findByQuery (entityInformation .getJavaType ()).consistentWith (buildQueryScanConsistency ())
206217 .matching (query ).all ();
207218 }
@@ -219,7 +230,7 @@ private QueryScanConsistency buildQueryScanConsistency() {
219230 *
220231 * @param crudMethodMetadata the injected repository metadata.
221232 */
222- void setRepositoryMethodMetadata (CrudMethodMetadata crudMethodMetadata ) {
233+ void setRepositoryMethodMetadata (final CrudMethodMetadata crudMethodMetadata ) {
223234 this .crudMethodMetadata = crudMethodMetadata ;
224235 }
225236
0 commit comments