Skip to content

Commit a7d84f1

Browse files
committed
Add ByteUtils utility static class for byte array/string conversions
Re-order author tags correctly Remove excessive final modifiers Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
1 parent 349c095 commit a7d84f1

19 files changed

Lines changed: 165 additions & 79 deletions

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

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

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

19-
import java.nio.charset.StandardCharsets;
19+
import org.springframework.data.couchbase.core.util.ByteUtils;
2020
import java.time.Duration;
2121

2222
import org.springframework.cache.Cache;
@@ -60,7 +60,8 @@ public static CouchbaseCacheConfiguration defaultCacheConfig() {
6060
}
6161

6262
/**
63-
* Registers default cache key converters. The following converters get registered:
63+
* Registers default cache key converters. The following converters get
64+
* registered:
6465
* <ul>
6566
* <li>{@link String} to byte using UTF-8 encoding.</li>
6667
* <li>{@link SimpleKey} to {@link String}</li>
@@ -70,12 +71,13 @@ public static CouchbaseCacheConfiguration defaultCacheConfig() {
7071
*/
7172
public static void registerDefaultConverters(final ConverterRegistry registry) {
7273
Assert.notNull(registry, "ConverterRegistry must not be null!");
73-
registry.addConverter(String.class, byte[].class, source -> source.getBytes(StandardCharsets.UTF_8));
74+
registry.addConverter(String.class, byte[].class, ByteUtils::getBytes);
7475
registry.addConverter(SimpleKey.class, String.class, SimpleKey::toString);
7576
}
7677

7778
/**
78-
* Set the expiry to apply for cache entries. Use {@link Duration#ZERO} to declare an eternal cache.
79+
* Set the expiry to apply for cache entries. Use {@link Duration#ZERO} to
80+
* declare an eternal cache.
7981
*
8082
* @param expiry must not be {@literal null}.
8183
* @return new {@link CouchbaseCacheConfiguration}.
@@ -112,9 +114,13 @@ public CouchbaseCacheConfiguration valueTranscoder(final Transcoder valueTransco
112114

113115
/**
114116
* Disable caching {@literal null} values. <br />
115-
* <strong>NOTE</strong> any {@link org.springframework.cache.Cache#put(Object, Object)} operation involving
116-
* {@literal null} value will error. Nothing will be written to Couchbase, nothing will be removed. An already
117-
* existing key will still be there afterwards with the very same value as before.
117+
* <strong>NOTE</strong> any
118+
* {@link org.springframework.cache.Cache#put(Object, Object)} operation
119+
* involving
120+
* {@literal null} value will error. Nothing will be written to Couchbase,
121+
* nothing will be removed. An already
122+
* existing key will still be there afterwards with the very same value as
123+
* before.
118124
*
119125
* @return new {@link CouchbaseCacheConfiguration}.
120126
*/
@@ -124,8 +130,10 @@ public CouchbaseCacheConfiguration disableCachingNullValues() {
124130
}
125131

126132
/**
127-
* Prefix the {@link CouchbaseCache#getName() cache name} with the given value. <br />
128-
* The generated cache key will be: {@code prefix + cache name + "::" + cache entry key}.
133+
* Prefix the {@link CouchbaseCache#getName() cache name} with the given value.
134+
* <br />
135+
* The generated cache key will be:
136+
* {@code prefix + cache name + "::" + cache entry key}.
129137
*
130138
* @param prefix the prefix to prepend to the cache name.
131139
* @return this.
@@ -137,7 +145,8 @@ public CouchbaseCacheConfiguration prefixCacheNameWith(final String prefix) {
137145
}
138146

139147
/**
140-
* Use the given {@link CacheKeyPrefix} to compute the prefix for the actual Couchbase {@literal key} given the
148+
* Use the given {@link CacheKeyPrefix} to compute the prefix for the actual
149+
* Couchbase {@literal key} given the
141150
* {@literal cache name} as function input.
142151
*
143152
* @param cacheKeyPrefix must not be {@literal null}.
@@ -165,14 +174,16 @@ public boolean getAllowCacheNullValues() {
165174
}
166175

167176
/**
168-
* @return The {@link ConversionService} used for cache key to {@link String} conversion. Never {@literal null}.
177+
* @return The {@link ConversionService} used for cache key to {@link String}
178+
* conversion. Never {@literal null}.
169179
*/
170180
public ConversionService getConversionService() {
171181
return conversionService;
172182
}
173183

174184
/**
175-
* @return {@literal true} if cache keys need to be prefixed with the {@link #getKeyPrefixFor(String)} if present or
185+
* @return {@literal true} if cache keys need to be prefixed with the
186+
* {@link #getKeyPrefixFor(String)} if present or
176187
* the default which resolves to {@link Cache#getName()}.
177188
*/
178189
public boolean usePrefix() {
@@ -197,7 +208,8 @@ public Transcoder getValueTranscoder() {
197208
}
198209

199210
/**
200-
* The name of the collection to use for this cache - if empty uses the default collection.
211+
* The name of the collection to use for this cache - if empty uses the default
212+
* collection.
201213
*/
202214
public String getCollectionName() {
203215
return collectionName;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
/**
4747
* Base shared by Reactive and non-Reactive TemplateSupport
4848
*
49-
* @author Emilien Bevierre
5049
* @author Michael Reiche
50+
* @author Emilien Bevierre
5151
*/
5252
@Stability.Internal
5353
public abstract class AbstractTemplateSupport {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
/**
3636
* Internal encode/decode support for CouchbaseTemplate.
3737
*
38-
* @author Emilien Bevierre
3938
* @author Michael Nitschinger
4039
* @author Michael Reiche
4140
* @author Jorge Rodriguez Martin
4241
* @author Carlos Espinaco
42+
* @author Emilien Bevierre
4343
* @since 3.0
4444
*/
4545
class CouchbaseTemplateSupport extends AbstractTemplateSupport implements ApplicationContextAware, TemplateSupport {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
/**
2727
* Wrapper of {@link TemplateSupport} methods to adapt them to {@link ReactiveTemplateSupport}.
2828
*
29-
* @author Emilien Bevierre
3029
* @author Carlos Espinaco
3130
* @author Michael Reiche
31+
* @author Emilien Bevierre
3232
* @since 4.2
3333
*/
3434
public class NonReactiveSupportWrapper implements ReactiveTemplateSupport {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
/**
3939
* Internal encode/decode support for {@link ReactiveCouchbaseTemplate}.
4040
*
41-
* @author Emilien Bevierre
4241
* @author Carlos Espinaco
4342
* @author Michael Reiche
43+
* @author Emilien Bevierre
4444
* @since 4.2
4545
*/
4646
class ReactiveCouchbaseTemplateSupport extends AbstractTemplateSupport

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
/**
4747
* {@link ReactiveFindByIdOperation} implementations for Couchbase.
4848
*
49-
* @author Emilien Bevierre
5049
* @author Michael Reiche
5150
* @author Tigran Babloyan
51+
* @author Emilien Bevierre
5252
*/
5353
public class ReactiveFindByIdOperationSupport implements ReactiveFindByIdOperation {
5454

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
/**
3333
* {@link ReactiveFindFromReplicasByIdOperation} implementations for Couchbase.
3434
*
35-
* @author Emilien Bevierre
3635
* @author Michael Reiche
36+
* @author Emilien Bevierre
3737
*/
3838
public class ReactiveFindFromReplicasByIdOperationSupport implements ReactiveFindFromReplicasByIdOperation {
3939

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
/**
4444
* {@link ReactiveInsertByIdOperation} implementations for Couchbase.
4545
*
46-
* @author Emilien Bevierre
4746
* @author Michael Reiche
4847
* @author Tigran Babloyan
48+
* @author Emilien Bevierre
4949
*/
5050
public class ReactiveInsertByIdOperationSupport implements ReactiveInsertByIdOperation {
5151

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
/**
3232
* {@link ReactiveRangeScanOperationSupport} implementations for Couchbase.
3333
*
34-
* @author Emilien Bevierre
3534
* @author Michael Reiche
35+
* @author Emilien Bevierre
3636
*/
3737
public class ReactiveRangeScanOperationSupport implements ReactiveRangeScanOperation {
3838

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
/**
4545
* {@link ReactiveRemoveByIdOperation} implementations for Couchbase.
4646
*
47-
* @author Emilien Bevierre
4847
* @author Michael Reiche
4948
* @author Tigran Babloyan
49+
* @author Emilien Bevierre
5050
*/
5151
public class ReactiveRemoveByIdOperationSupport implements ReactiveRemoveByIdOperation {
5252

0 commit comments

Comments
 (0)