Skip to content

Commit d99f336

Browse files
committed
Revert "DATACOUCH-650 - Polishing."
This reverts commit eee83f7.
1 parent 4b75425 commit d99f336

File tree

3 files changed

+62
-54
lines changed

3 files changed

+62
-54
lines changed

pom.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<properties>
2121
<couchbase>3.0.10</couchbase>
2222
<couchbase.osgi>3.0.10</couchbase.osgi>
23-
<springdata.commons>2.5.0-SNAPSHOT</springdata.commons>
23+
<springdata.commons>2.4.0-DATACMNS-800-SNAPSHOT</springdata.commons>
2424
<java-module-name>spring.data.couchbase</java-module-name>
2525
</properties>
2626

@@ -41,12 +41,10 @@
4141
<groupId>org.springframework</groupId>
4242
<artifactId>spring-context-support</artifactId>
4343
</dependency>
44-
4544
<dependency>
4645
<groupId>org.springframework</groupId>
4746
<artifactId>spring-web</artifactId>
4847
</dependency>
49-
5048
<dependency>
5149
<groupId>org.springframework</groupId>
5250
<artifactId>spring-tx</artifactId>
@@ -176,14 +174,12 @@
176174
<version>${kotlin}</version>
177175
<optional>true</optional>
178176
</dependency>
179-
180177
<dependency>
181178
<groupId>org.jetbrains.kotlin</groupId>
182179
<artifactId>kotlin-reflect</artifactId>
183180
<version>${kotlin}</version>
184181
<optional>true</optional>
185182
</dependency>
186-
187183
<dependency>
188184
<groupId>org.jetbrains.kotlin</groupId>
189185
<artifactId>kotlin-test</artifactId>

src/main/java/org/springframework/data/couchbase/repository/support/SimpleCouchbaseRepository.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.data.couchbase.repository.support;
1818

19-
import static org.springframework.data.couchbase.repository.support.Util.*;
20-
2119
import java.util.Collection;
2220
import java.util.List;
2321
import java.util.Objects;
@@ -28,6 +26,7 @@
2826
import org.springframework.data.couchbase.core.query.Query;
2927
import org.springframework.data.couchbase.repository.CouchbaseRepository;
3028
import org.springframework.data.couchbase.repository.query.CouchbaseEntityInformation;
29+
import static org.springframework.data.couchbase.repository.support.Util.hasNonZeroVersionProperty;
3130
import org.springframework.data.domain.Page;
3231
import org.springframework.data.domain.PageImpl;
3332
import org.springframework.data.domain.Pageable;
@@ -65,8 +64,8 @@ public class SimpleCouchbaseRepository<T, ID> implements CouchbaseRepository<T,
6564
* @param entityInformation the Metadata for the entity.
6665
* @param couchbaseOperations the reference to the template used.
6766
*/
68-
public SimpleCouchbaseRepository(CouchbaseEntityInformation<T, String> entityInformation,
69-
CouchbaseOperations couchbaseOperations) {
67+
public SimpleCouchbaseRepository(final CouchbaseEntityInformation<T, String> entityInformation,
68+
final CouchbaseOperations couchbaseOperations) {
7069
Assert.notNull(entityInformation, "CouchbaseEntityInformation must not be null!");
7170
Assert.notNull(couchbaseOperations, "CouchbaseOperations must not be null!");
7271

@@ -76,7 +75,7 @@ public SimpleCouchbaseRepository(CouchbaseEntityInformation<T, String> entityInf
7675

7776
@Override
7877
@SuppressWarnings("unchecked")
79-
public <S extends T> S save(S entity) {
78+
public <S extends T> S save(final S entity) {
8079
Assert.notNull(entity, "Entity must not be null!");
8180
// if entity has non-null, non-zero version property, then replace()
8281
if (hasNonZeroVersionProperty(entity, couchbaseOperations.getConverter())) {
@@ -87,53 +86,55 @@ public <S extends T> S save(S entity) {
8786
}
8887

8988
@Override
90-
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
89+
@SuppressWarnings("unchecked")
90+
public <S extends T> Iterable<S> saveAll(final Iterable<S> entities) {
9191
Assert.notNull(entities, "The given Iterable of entities must not be null!");
9292
return Streamable.of(entities).stream().map((e) -> save(e)).collect(StreamUtils.toUnmodifiableList());
9393
}
9494

9595
@Override
96-
public Optional<T> findById(ID id) {
96+
public Optional<T> findById(final ID id) {
9797
Assert.notNull(id, "The given id must not be null!");
9898
return Optional.ofNullable(couchbaseOperations.findById(entityInformation.getJavaType()).one(id.toString()));
9999
}
100100

101101
@Override
102-
public List<T> findAllById(Iterable<ID> ids) {
102+
@SuppressWarnings("unchecked")
103+
public List<T> findAllById(final Iterable<ID> ids) {
103104
Assert.notNull(ids, "The given Iterable of ids must not be null!");
104105
List<String> convertedIds = Streamable.of(ids).stream().map(Objects::toString).collect(Collectors.toList());
105106
Collection<? extends T> all = couchbaseOperations.findById(entityInformation.getJavaType()).all(convertedIds);
106107
return Streamable.of(all).stream().collect(StreamUtils.toUnmodifiableList());
107108
}
108109

109110
@Override
110-
public boolean existsById(ID id) {
111+
public boolean existsById(final ID id) {
111112
Assert.notNull(id, "The given id must not be null!");
112113
return couchbaseOperations.existsById().one(id.toString());
113114
}
114115

115116
@Override
116-
public void deleteById(ID id) {
117+
public void deleteById(final ID id) {
117118
Assert.notNull(id, "The given id must not be null!");
118119
couchbaseOperations.removeById().one(id.toString());
119120
}
120121

121122
@Override
122-
public void delete(T entity) {
123+
public void delete(final T entity) {
123124
Assert.notNull(entity, "Entity must not be null!");
124125
couchbaseOperations.removeById().one(entityInformation.getId(entity));
125126
}
126127

127128
@Override
128-
public void deleteAllById(Iterable<? extends ID> ids) {
129-
Assert.notNull(ids, "The given Iterable of ids must not be null!");
130-
couchbaseOperations.removeById().all(Streamable.of(ids).map(Objects::toString).toList());
129+
public void deleteAll(final Iterable<? extends T> entities) {
130+
Assert.notNull(entities, "The given Iterable of entities must not be null!");
131+
couchbaseOperations.removeById().all(Streamable.of(entities).map(entityInformation::getId).toList());
131132
}
132133

133134
@Override
134-
public void deleteAll(Iterable<? extends T> entities) {
135-
Assert.notNull(entities, "The given Iterable of entities must not be null!");
136-
couchbaseOperations.removeById().all(Streamable.of(entities).map(entityInformation::getId).toList());
135+
public void deleteAllById(Iterable<? extends ID> ids) {
136+
Assert.notNull(ids, "The given Iterable of ids must not be null!");
137+
couchbaseOperations.removeById().all(Streamable.of(ids).map(Objects::toString).toList());
137138
}
138139

139140
@Override
@@ -154,17 +155,17 @@ public List<T> findAll() {
154155
}
155156

156157
@Override
157-
public List<T> findAll(Sort sort) {
158+
public List<T> findAll(final Sort sort) {
158159
return findAll(new Query().with(sort));
159160
}
160161

161162
@Override
162-
public List<T> findAll(QueryScanConsistency queryScanConsistency) {
163+
public List<T> findAll(final QueryScanConsistency queryScanConsistency) {
163164
return findAll(new Query().scanConsistency(queryScanConsistency));
164165
}
165166

166167
@Override
167-
public Page<T> findAll(Pageable pageable) {
168+
public Page<T> findAll(final Pageable pageable) {
168169
List<T> results = findAll(new Query().with(pageable));
169170
return new PageImpl<>(results, pageable, count());
170171
}
@@ -184,7 +185,7 @@ protected CouchbaseEntityInformation<T, String> getEntityInformation() {
184185
* @param query the originating query.
185186
* @return the list of found entities, already executed.
186187
*/
187-
private List<T> findAll(Query query) {
188+
private List<T> findAll(final Query query) {
188189
return couchbaseOperations.findByQuery(entityInformation.getJavaType()).consistentWith(buildQueryScanConsistency())
189190
.matching(query).all();
190191
}
@@ -202,7 +203,7 @@ private QueryScanConsistency buildQueryScanConsistency() {
202203
*
203204
* @param crudMethodMetadata the injected repository metadata.
204205
*/
205-
void setRepositoryMethodMetadata(CrudMethodMetadata crudMethodMetadata) {
206+
void setRepositoryMethodMetadata(final CrudMethodMetadata crudMethodMetadata) {
206207
this.crudMethodMetadata = crudMethodMetadata;
207208
}
208209

src/main/java/org/springframework/data/couchbase/repository/support/SimpleReactiveCouchbaseRepository.java

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.data.couchbase.repository.support;
1818

19-
import static org.springframework.data.couchbase.repository.support.Util.*;
20-
2119
import reactor.core.publisher.Flux;
2220
import reactor.core.publisher.Mono;
2321

@@ -26,12 +24,12 @@
2624
import java.util.stream.Collectors;
2725

2826
import org.reactivestreams.Publisher;
29-
3027
import org.springframework.data.couchbase.core.CouchbaseOperations;
3128
import org.springframework.data.couchbase.core.ReactiveCouchbaseOperations;
3229
import org.springframework.data.couchbase.core.query.Query;
3330
import org.springframework.data.couchbase.repository.ReactiveCouchbaseRepository;
3431
import org.springframework.data.couchbase.repository.query.CouchbaseEntityInformation;
32+
import static org.springframework.data.couchbase.repository.support.Util.hasNonZeroVersionProperty;
3533
import org.springframework.data.domain.Sort;
3634
import org.springframework.data.util.Streamable;
3735
import 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

Comments
 (0)