Skip to content

Commit af96081

Browse files
committed
DATACOUCH-504 - Apply eclipse formatting rules.
1 parent b1ed894 commit af96081

33 files changed

+264
-353
lines changed

src/main/java/org/springframework/data/couchbase/SimpleCouchbaseClientFactory.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616

1717
package org.springframework.data.couchbase;
1818

19-
import com.couchbase.client.core.env.OwnedSupplier;
20-
import com.couchbase.client.java.env.ClusterEnvironment;
19+
import java.util.function.Supplier;
20+
2121
import org.springframework.dao.support.PersistenceExceptionTranslator;
2222
import org.springframework.data.couchbase.core.CouchbaseExceptionTranslator;
2323

2424
import com.couchbase.client.core.env.Authenticator;
25+
import com.couchbase.client.core.env.OwnedSupplier;
2526
import com.couchbase.client.core.io.CollectionIdentifier;
2627
import com.couchbase.client.java.Bucket;
2728
import com.couchbase.client.java.Cluster;
2829
import com.couchbase.client.java.ClusterOptions;
2930
import com.couchbase.client.java.Collection;
3031
import com.couchbase.client.java.Scope;
31-
32-
import java.util.function.Supplier;
32+
import com.couchbase.client.java.env.ClusterEnvironment;
3333

3434
public class SimpleCouchbaseClientFactory implements CouchbaseClientFactory {
3535

@@ -45,19 +45,24 @@ public SimpleCouchbaseClientFactory(final String connectionString, final Authent
4545

4646
public SimpleCouchbaseClientFactory(final String connectionString, final Authenticator authenticator,
4747
final String bucketName, final String scopeName) {
48-
this(new OwnedSupplier<>(Cluster.connect(connectionString, ClusterOptions.clusterOptions(authenticator))), bucketName, scopeName);
48+
this(new OwnedSupplier<>(Cluster.connect(connectionString, ClusterOptions.clusterOptions(authenticator))),
49+
bucketName, scopeName);
4950
}
5051

5152
public SimpleCouchbaseClientFactory(final String connectionString, final Authenticator authenticator,
52-
final String bucketName, final String scopeName, final ClusterEnvironment environment) {
53-
this(new OwnedSupplier<>(Cluster.connect(connectionString, ClusterOptions.clusterOptions(authenticator).environment(environment))), bucketName, scopeName);
53+
final String bucketName, final String scopeName, final ClusterEnvironment environment) {
54+
this(
55+
new OwnedSupplier<>(
56+
Cluster.connect(connectionString, ClusterOptions.clusterOptions(authenticator).environment(environment))),
57+
bucketName, scopeName);
5458
}
5559

5660
public SimpleCouchbaseClientFactory(final Cluster cluster, final String bucketName, final String scopeName) {
5761
this(() -> cluster, bucketName, scopeName);
5862
}
5963

60-
private SimpleCouchbaseClientFactory(final Supplier<Cluster> cluster, final String bucketName, final String scopeName) {
64+
private SimpleCouchbaseClientFactory(final Supplier<Cluster> cluster, final String bucketName,
65+
final String scopeName) {
6166
this.cluster = cluster;
6267
this.bucket = cluster.get().bucket(bucketName);
6368
this.scope = scopeName == null ? bucket.defaultScope() : bucket.scope(scopeName);

src/main/java/org/springframework/data/couchbase/cache/CouchbaseCacheManager.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public class CouchbaseCacheManager extends AbstractTransactionSupportingCacheMan
4848
* @param allowInFlightCacheCreation allow create unconfigured caches.
4949
*/
5050
private CouchbaseCacheManager(final CouchbaseCacheWriter cacheWriter,
51-
final CouchbaseCacheConfiguration defaultCacheConfiguration,
52-
final Map<String, CouchbaseCacheConfiguration> initialCacheConfiguration,
53-
final boolean allowInFlightCacheCreation) {
51+
final CouchbaseCacheConfiguration defaultCacheConfiguration,
52+
final Map<String, CouchbaseCacheConfiguration> initialCacheConfiguration,
53+
final boolean allowInFlightCacheCreation) {
5454

5555
Assert.notNull(cacheWriter, "CacheWriter must not be null!");
5656
Assert.notNull(defaultCacheConfiguration, "DefaultCacheConfiguration must not be null!");
@@ -70,7 +70,7 @@ private CouchbaseCacheManager(final CouchbaseCacheWriter cacheWriter,
7070
public static CouchbaseCacheManager create(CouchbaseClientFactory clientFactory) {
7171
Assert.notNull(clientFactory, "ConnectionFactory must not be null!");
7272
return new CouchbaseCacheManager(new DefaultCouchbaseCacheWriter(clientFactory),
73-
CouchbaseCacheConfiguration.defaultCacheConfig(), new LinkedHashMap<>(), true);
73+
CouchbaseCacheConfiguration.defaultCacheConfig(), new LinkedHashMap<>(), true);
7474
}
7575

7676
/**
@@ -126,10 +126,10 @@ protected CouchbaseCache createCouchbaseCache(final String name,
126126
public static class CouchbaseCacheManagerBuilder {
127127

128128
private final CouchbaseCacheWriter cacheWriter;
129-
private CouchbaseCacheConfiguration defaultCacheConfiguration = CouchbaseCacheConfiguration.defaultCacheConfig();
130129
private final Map<String, CouchbaseCacheConfiguration> initialCaches = new LinkedHashMap<>();
131-
private boolean enableTransactions;
132130
boolean allowInFlightCacheCreation = true;
131+
private CouchbaseCacheConfiguration defaultCacheConfiguration = CouchbaseCacheConfiguration.defaultCacheConfig();
132+
private boolean enableTransactions;
133133

134134
private CouchbaseCacheManagerBuilder(CouchbaseCacheWriter cacheWriter) {
135135
this.cacheWriter = cacheWriter;
@@ -170,7 +170,8 @@ public CouchbaseCacheManagerBuilder cacheDefaults(CouchbaseCacheConfiguration de
170170
}
171171

172172
/**
173-
* Enable {@link CouchbaseCache}s to synchronize cache put/evict operations with ongoing Spring-managed transactions.
173+
* Enable {@link CouchbaseCache}s to synchronize cache put/evict operations with ongoing Spring-managed
174+
* transactions.
174175
*
175176
* @return this {@link CouchbaseCacheManagerBuilder}.
176177
*/
@@ -200,11 +201,11 @@ public CouchbaseCacheManagerBuilder initialCacheNames(Set<String> cacheNames) {
200201
* @return this {@link CouchbaseCacheManagerBuilder}.
201202
*/
202203
public CouchbaseCacheManagerBuilder withInitialCacheConfigurations(
203-
Map<String, CouchbaseCacheConfiguration> cacheConfigurations) {
204+
Map<String, CouchbaseCacheConfiguration> cacheConfigurations) {
204205

205206
Assert.notNull(cacheConfigurations, "CacheConfigurations must not be null!");
206207
cacheConfigurations.forEach((cacheName, configuration) -> Assert.notNull(configuration,
207-
String.format("CouchbaseCacheConfiguration for cache %s must not be null!", cacheName)));
208+
String.format("CouchbaseCacheConfiguration for cache %s must not be null!", cacheName)));
208209

209210
this.initialCaches.putAll(cacheConfigurations);
210211
return this;
@@ -216,7 +217,7 @@ public CouchbaseCacheManagerBuilder withInitialCacheConfigurations(
216217
* @return this {@link CouchbaseCacheManagerBuilder}.
217218
*/
218219
public CouchbaseCacheManagerBuilder withCacheConfiguration(String cacheName,
219-
CouchbaseCacheConfiguration cacheConfiguration) {
220+
CouchbaseCacheConfiguration cacheConfiguration) {
220221

221222
Assert.notNull(cacheName, "CacheName must not be null!");
222223
Assert.notNull(cacheConfiguration, "CacheConfiguration must not be null!");
@@ -267,7 +268,7 @@ public Optional<CouchbaseCacheConfiguration> getCacheConfigurationFor(String cac
267268
*/
268269
public CouchbaseCacheManager build() {
269270
CouchbaseCacheManager cm = new CouchbaseCacheManager(cacheWriter, defaultCacheConfiguration, initialCaches,
270-
allowInFlightCacheCreation);
271+
allowInFlightCacheCreation);
271272
cm.setTransactionAware(enableTransactions);
272273
return cm;
273274
}

src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
package org.springframework.data.couchbase.config;
1818

19+
import static com.couchbase.client.java.ClusterOptions.*;
20+
1921
import java.util.Collections;
2022
import java.util.HashSet;
2123
import java.util.Set;
2224

23-
import com.couchbase.client.java.Cluster;
2425
import org.springframework.beans.factory.config.BeanDefinition;
2526
import org.springframework.context.annotation.Bean;
2627
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
@@ -49,11 +50,10 @@
4950
import com.couchbase.client.core.deps.com.fasterxml.jackson.databind.DeserializationFeature;
5051
import com.couchbase.client.core.env.Authenticator;
5152
import com.couchbase.client.core.env.PasswordAuthenticator;
53+
import com.couchbase.client.java.Cluster;
5254
import com.couchbase.client.java.env.ClusterEnvironment;
5355
import com.couchbase.client.java.json.JacksonTransformers;
5456

55-
import static com.couchbase.client.java.ClusterOptions.*;
56-
5757
/**
5858
* Base class for Spring Data Couchbase configuration using JavaConfig.
5959
*
@@ -88,10 +88,8 @@ public CouchbaseClientFactory couchbaseClientFactory(Cluster couchbaseCluster) {
8888

8989
@Bean(destroyMethod = "disconnect")
9090
public Cluster couchbaseCluster(ClusterEnvironment couchbaseClusterEnvironment) {
91-
return Cluster.connect(
92-
getConnectionString(),
93-
clusterOptions(authenticator()).environment(couchbaseClusterEnvironment)
94-
);
91+
return Cluster.connect(getConnectionString(),
92+
clusterOptions(authenticator()).environment(couchbaseClusterEnvironment));
9593
}
9694

9795
@Bean(destroyMethod = "shutdown")
@@ -107,13 +105,13 @@ protected void configureEnvironment(final ClusterEnvironment.Builder builder) {
107105

108106
@Bean(name = BeanNames.COUCHBASE_TEMPLATE)
109107
public CouchbaseTemplate couchbaseTemplate(CouchbaseClientFactory couchbaseClientFactory,
110-
MappingCouchbaseConverter mappingCouchbaseConverter) {
108+
MappingCouchbaseConverter mappingCouchbaseConverter) {
111109
return new CouchbaseTemplate(couchbaseClientFactory, mappingCouchbaseConverter);
112110
}
113111

114112
@Bean(name = BeanNames.REACTIVE_COUCHBASE_TEMPLATE)
115113
public ReactiveCouchbaseTemplate reactiveCouchbaseTemplate(CouchbaseClientFactory couchbaseClientFactory,
116-
MappingCouchbaseConverter mappingCouchbaseConverter) {
114+
MappingCouchbaseConverter mappingCouchbaseConverter) {
117115
return new ReactiveCouchbaseTemplate(couchbaseClientFactory, mappingCouchbaseConverter);
118116
}
119117

@@ -137,9 +135,11 @@ protected void configureRepositoryOperationsMapping(RepositoryOperationsMapping
137135
}
138136

139137
@Bean(name = BeanNames.REACTIVE_COUCHBASE_OPERATIONS_MAPPING)
140-
public ReactiveRepositoryOperationsMapping reactiveCouchbaseRepositoryOperationsMapping(ReactiveCouchbaseTemplate reactiveCouchbaseTemplate) {
138+
public ReactiveRepositoryOperationsMapping reactiveCouchbaseRepositoryOperationsMapping(
139+
ReactiveCouchbaseTemplate reactiveCouchbaseTemplate) {
141140
// create a base mapping that associates all repositories to the default template
142-
ReactiveRepositoryOperationsMapping baseMapping = new ReactiveRepositoryOperationsMapping(reactiveCouchbaseTemplate);
141+
ReactiveRepositoryOperationsMapping baseMapping = new ReactiveRepositoryOperationsMapping(
142+
reactiveCouchbaseTemplate);
143143
// let the user tune it
144144
configureReactiveRepositoryOperationsMapping(baseMapping);
145145
return baseMapping;
@@ -179,8 +179,8 @@ protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
179179

180180
/**
181181
* Determines the name of the field that will store the type information for complex types when using the
182-
* {@link #mappingCouchbaseConverter(CouchbaseMappingContext, CouchbaseCustomConversions)}. Defaults
183-
* to {@value MappingCouchbaseConverter#TYPEKEY_DEFAULT}.
182+
* {@link #mappingCouchbaseConverter(CouchbaseMappingContext, CouchbaseCustomConversions)}. Defaults to
183+
* {@value MappingCouchbaseConverter#TYPEKEY_DEFAULT}.
184184
*
185185
* @see MappingCouchbaseConverter#TYPEKEY_DEFAULT
186186
* @see MappingCouchbaseConverter#TYPEKEY_SYNCGATEWAY_COMPATIBLE
@@ -196,7 +196,7 @@ public String typeKey() {
196196
*/
197197
@Bean
198198
public MappingCouchbaseConverter mappingCouchbaseConverter(CouchbaseMappingContext couchbaseMappingContext,
199-
CouchbaseCustomConversions couchbaseCustomConversions) {
199+
CouchbaseCustomConversions couchbaseCustomConversions) {
200200
MappingCouchbaseConverter converter = new MappingCouchbaseConverter(couchbaseMappingContext, typeKey());
201201
converter.setCustomConversions(couchbaseCustomConversions);
202202
return converter;
@@ -234,8 +234,7 @@ public CouchbaseMappingContext couchbaseMappingContext(CustomConversions customC
234234
}
235235

236236
/**
237-
* Configure whether to automatically create indices for domain types by deriving the
238-
* from the entity or not.
237+
* Configure whether to automatically create indices for domain types by deriving the from the entity or not.
239238
*/
240239
protected boolean autoIndexCreation() {
241240
return false;

src/main/java/org/springframework/data/couchbase/config/BeanNames.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616

1717
package org.springframework.data.couchbase.config;
1818

19-
import org.springframework.core.convert.converter.Converter;
20-
import org.springframework.data.couchbase.CouchbaseClientFactory;
21-
import org.springframework.data.couchbase.core.CouchbaseOperations;
22-
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
23-
import org.springframework.data.couchbase.core.convert.translation.TranslationService;
24-
2519
/**
2620
* Contains default bean names for Couchbase beans. These are the names of the beans used by Spring Data Couchbase,
2721
* unless an explicit id is given to the bean either in the xml configuration or the

src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
import org.springframework.dao.support.PersistenceExceptionTranslator;
2525
import org.springframework.data.couchbase.CouchbaseClientFactory;
2626
import org.springframework.data.couchbase.core.convert.CouchbaseConverter;
27-
28-
import com.couchbase.client.java.Collection;
2927
import org.springframework.data.couchbase.core.index.CouchbasePersistentEntityIndexCreator;
3028
import org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext;
3129
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
3230
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
3331
import org.springframework.data.mapping.context.MappingContext;
3432
import org.springframework.lang.Nullable;
3533

34+
import com.couchbase.client.java.Collection;
35+
3636
public class CouchbaseTemplate implements CouchbaseOperations, ApplicationContextAware {
3737

3838
private final CouchbaseClientFactory clientFactory;
@@ -43,7 +43,6 @@ public class CouchbaseTemplate implements CouchbaseOperations, ApplicationContex
4343
private final ReactiveCouchbaseTemplate reactiveCouchbaseTemplate;
4444
private @Nullable CouchbasePersistentEntityIndexCreator indexCreator;
4545

46-
4746
public CouchbaseTemplate(final CouchbaseClientFactory clientFactory, final CouchbaseConverter converter) {
4847
this.clientFactory = clientFactory;
4948
this.converter = converter;
@@ -168,7 +167,8 @@ private void prepareIndexCreator(ApplicationContext context) {
168167
String[] indexCreators = context.getBeanNamesForType(CouchbasePersistentEntityIndexCreator.class);
169168

170169
for (String creator : indexCreators) {
171-
CouchbasePersistentEntityIndexCreator creatorBean = context.getBean(creator, CouchbasePersistentEntityIndexCreator.class);
170+
CouchbasePersistentEntityIndexCreator creatorBean = context.getBean(creator,
171+
CouchbasePersistentEntityIndexCreator.class);
172172
if (creatorBean.isIndexCreatorFor(mappingContext)) {
173173
return;
174174
}

src/main/java/org/springframework/data/couchbase/core/ReactiveFindByQueryOperationSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package org.springframework.data.couchbase.core;
1717

18-
import org.springframework.data.couchbase.core.query.QueryCriteria;
1918
import reactor.core.publisher.Flux;
2019
import reactor.core.publisher.Mono;
2120

2221
import org.springframework.data.couchbase.core.query.Query;
22+
import org.springframework.data.couchbase.core.query.QueryCriteria;
2323

2424
import com.couchbase.client.java.query.QueryOptions;
2525
import com.couchbase.client.java.query.QueryScanConsistency;

src/main/java/org/springframework/data/couchbase/core/index/CouchbasePersistentEntityIndexCreator.java

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,24 @@
1515
*/
1616
package org.springframework.data.couchbase.core.index;
1717

18-
import com.couchbase.client.core.error.IndexExistsException;
19-
import com.couchbase.client.java.Cluster;
18+
import java.util.Map;
19+
import java.util.concurrent.ConcurrentHashMap;
20+
2021
import org.slf4j.Logger;
2122
import org.slf4j.LoggerFactory;
2223
import org.springframework.context.ApplicationListener;
2324
import org.springframework.dao.DataIntegrityViolationException;
2425
import org.springframework.data.couchbase.core.CouchbaseOperations;
26+
import org.springframework.data.couchbase.core.index.CouchbasePersistentEntityIndexResolver.IndexDefinitionHolder;
2527
import org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext;
2628
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
2729
import org.springframework.data.couchbase.core.mapping.Document;
2830
import org.springframework.data.mapping.PersistentEntity;
2931
import org.springframework.data.mapping.context.MappingContext;
3032
import org.springframework.data.mapping.context.MappingContextEvent;
31-
import org.springframework.data.couchbase.core.index.CouchbasePersistentEntityIndexResolver.IndexDefinitionHolder;
32-
import org.springframework.util.StringUtils;
3333

34-
import java.util.List;
35-
import java.util.Map;
36-
import java.util.concurrent.ConcurrentHashMap;
37-
import java.util.stream.Collectors;
34+
import com.couchbase.client.core.error.IndexExistsException;
35+
import com.couchbase.client.java.Cluster;
3836

3937
public class CouchbasePersistentEntityIndexCreator implements ApplicationListener<MappingContextEvent<?, ?>> {
4038

@@ -46,7 +44,7 @@ public class CouchbasePersistentEntityIndexCreator implements ApplicationListene
4644
private final CouchbaseOperations couchbaseOperations;
4745

4846
public CouchbasePersistentEntityIndexCreator(final CouchbaseMappingContext mappingContext,
49-
final CouchbaseOperations operations) {
47+
final CouchbaseOperations operations) {
5048
this.mappingContext = mappingContext;
5149
this.couchbaseOperations = operations;
5250
this.indexResolver = QueryIndexResolver.create(mappingContext, operations);
@@ -85,8 +83,9 @@ private void checkForAndCreateIndexes(final CouchbasePersistentEntity<?> entity)
8583

8684
for (IndexDefinition indexDefinition : indexResolver.resolveIndexFor(entity.getTypeInformation())) {
8785
IndexDefinitionHolder indexToCreate = indexDefinition instanceof IndexDefinitionHolder
88-
? (IndexDefinitionHolder) indexDefinition
89-
: new IndexDefinitionHolder(indexDefinition.getIndexFields(), indexDefinition.getIndexName(), indexDefinition.getIndexPredicate());
86+
? (IndexDefinitionHolder) indexDefinition
87+
: new IndexDefinitionHolder(indexDefinition.getIndexFields(), indexDefinition.getIndexName(),
88+
indexDefinition.getIndexPredicate());
9089

9190
createIndex(indexToCreate);
9291
}
@@ -96,13 +95,9 @@ private void checkForAndCreateIndexes(final CouchbasePersistentEntity<?> entity)
9695
private void createIndex(final IndexDefinitionHolder indexToCreate) {
9796
Cluster cluster = couchbaseOperations.getCouchbaseClientFactory().getCluster();
9897

99-
StringBuilder statement = new StringBuilder("CREATE INDEX ")
100-
.append(indexToCreate.getIndexName())
101-
.append(" ON `")
102-
.append(couchbaseOperations.getBucketName())
103-
.append("` (")
104-
.append(String.join(",", indexToCreate.getIndexFields()))
105-
.append(")");
98+
StringBuilder statement = new StringBuilder("CREATE INDEX ").append(indexToCreate.getIndexName()).append(" ON `")
99+
.append(couchbaseOperations.getBucketName()).append("` (")
100+
.append(String.join(",", indexToCreate.getIndexFields())).append(")");
106101

107102
if (indexToCreate.getIndexPredicate() != null && !indexToCreate.getIndexPredicate().isEmpty()) {
108103
statement.append(" WHERE ").append(indexToCreate.getIndexPredicate());
@@ -114,8 +109,8 @@ private void createIndex(final IndexDefinitionHolder indexToCreate) {
114109
// ignored on purpose, rest is propagated
115110
LOGGER.debug("Index \"" + indexToCreate.getIndexName() + "\" already exists, ignoring.");
116111
} catch (Exception ex) {
117-
throw new DataIntegrityViolationException("Could not auto-create index with statement: "
118-
+ statement.toString(), ex);
112+
throw new DataIntegrityViolationException("Could not auto-create index with statement: " + statement.toString(),
113+
ex);
119114
}
120115
}
121116

0 commit comments

Comments
 (0)