Skip to content

Commit 202f02b

Browse files
committed
Remove final modifiers in var declaration and method parameters
Use String.formatted() for logging Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
1 parent a2a017a commit 202f02b

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

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

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ private <T> T decodeEntityBase(Object id, Long cas, Instant expiryTime, Class<T>
8787
CouchbasePersistentEntity persistentEntity = couldBePersistentEntity(entityClass);
8888

8989
if (persistentEntity == null) {
90-
final CouchbaseDocument converted = new CouchbaseDocument(id);
90+
CouchbaseDocument converted = new CouchbaseDocument(id);
9191
Set<Map.Entry<String, Object>> set = translatorFn.apply(translationService, converted).getContent()
9292
.entrySet();
9393
return (T) set.iterator().next().getValue();
9494
}
9595

96-
final CouchbaseDocument converted = prepareConvertedDocument(id, cas, persistentEntity);
96+
CouchbaseDocument converted = prepareConvertedDocument(id, cas, persistentEntity);
9797
T readEntity = converter.read(entityClass, translatorFn.apply(translationService, converted));
9898
return finalizeEntity(readEntity, id, cas, expiryTime, scope, collection, txResultHolder, holder);
9999
}
@@ -120,16 +120,15 @@ private CouchbaseDocument prepareConvertedDocument(Object id, Long cas,
120120
// TypeInformation<? extends R> typeToUse = typeMapper.readType(source, type);
121121

122122
if (id == null) {
123-
throw new CouchbaseException(
124-
TemplateUtils.SELECT_ID + " was null. Either use #{#n1ql.selectEntity} or project "
125-
+ TemplateUtils.SELECT_ID);
123+
throw new CouchbaseException("%s was null. Either use #{#n1ql.selectEntity} or project %s"
124+
.formatted(TemplateUtils.SELECT_ID, TemplateUtils.SELECT_ID));
126125
}
127126

128127
return getDocument(id, cas, persistentEntity);
129128
}
130129

131130
private static CouchbaseDocument getDocument(Object id, Long cas, CouchbasePersistentEntity persistentEntity) {
132-
final CouchbaseDocument converted = new CouchbaseDocument(id);
131+
CouchbaseDocument converted = new CouchbaseDocument(id);
133132

134133
// If possible, set the version property in the source so that if the
135134
// constructor has a long version argument, it will have a value and succeed,
@@ -140,9 +139,9 @@ private static CouchbaseDocument getDocument(Object id, Long cas, CouchbasePersi
140139
// not have a version property, in which case this won't be able to set the version.
141140
if (persistentEntity.getVersionProperty() != null) {
142141
if (cas == null) {
143-
throw new CouchbaseException("version/cas in the entity but " + TemplateUtils.SELECT_CAS
144-
+ " was not in result. Either use #{#n1ql.selectEntity} or project "
145-
+ TemplateUtils.SELECT_CAS);
142+
throw new CouchbaseException(
143+
"version/cas in the entity but %s was not in result. Either use #{#n1ql.selectEntity} or project %s"
144+
.formatted(TemplateUtils.SELECT_CAS, TemplateUtils.SELECT_CAS));
146145
}
147146
if (cas != 0) {
148147
converted.put(persistentEntity.getVersionProperty().getName(), cas);
@@ -153,7 +152,7 @@ private static CouchbaseDocument getDocument(Object id, Long cas, CouchbasePersi
153152

154153
private <T> T finalizeEntity(T readEntity, Object id, Long cas, Instant expiryTime, String scope, String collection,
155154
Object txResultHolder, CouchbaseResourceHolder holder) {
156-
final ConvertingPropertyAccessor<T> accessor = getPropertyAccessor(readEntity);
155+
ConvertingPropertyAccessor<T> accessor = getPropertyAccessor(readEntity);
157156

158157
CouchbasePersistentEntity persistentEntity = couldBePersistentEntity(readEntity.getClass());
159158

@@ -196,15 +195,15 @@ public <T> T applyResultBase(T entity, CouchbaseDocument converted, Object id, l
196195
Object txResultHolder, CouchbaseResourceHolder holder) {
197196
ConvertingPropertyAccessor<Object> accessor = getPropertyAccessor(entity);
198197

199-
final CouchbasePersistentEntity<?> persistentEntity = converter.getMappingContext()
198+
CouchbasePersistentEntity<?> persistentEntity = converter.getMappingContext()
200199
.getRequiredPersistentEntity(entity.getClass());
201200

202-
final CouchbasePersistentProperty idProperty = persistentEntity.getIdProperty();
201+
CouchbasePersistentProperty idProperty = persistentEntity.getIdProperty();
203202
if (idProperty != null) {
204203
accessor.setProperty(idProperty, id);
205204
}
206205

207-
final CouchbasePersistentProperty versionProperty = persistentEntity.getVersionProperty();
206+
CouchbasePersistentProperty versionProperty = persistentEntity.getVersionProperty();
208207
if (versionProperty != null) {
209208
accessor.setProperty(versionProperty, cas);
210209
}
@@ -217,11 +216,11 @@ public <T> T applyResultBase(T entity, CouchbaseDocument converted, Object id, l
217216

218217
}
219218

220-
public Long getCas(final Object entity) {
221-
final ConvertingPropertyAccessor<Object> accessor = getPropertyAccessor(entity);
222-
final CouchbasePersistentEntity<?> persistentEntity = mappingContext
219+
public Long getCas(Object entity) {
220+
ConvertingPropertyAccessor<Object> accessor = getPropertyAccessor(entity);
221+
CouchbasePersistentEntity<?> persistentEntity = mappingContext
223222
.getRequiredPersistentEntity(entity.getClass());
224-
final CouchbasePersistentProperty versionProperty = persistentEntity.getVersionProperty();
223+
CouchbasePersistentProperty versionProperty = persistentEntity.getVersionProperty();
225224
long cas = 0;
226225
if (versionProperty != null) {
227226
Object casObject = accessor.getProperty(versionProperty);
@@ -232,25 +231,25 @@ public Long getCas(final Object entity) {
232231
return cas;
233232
}
234233

235-
public Object getId(final Object entity) {
236-
final ConvertingPropertyAccessor<Object> accessor = getPropertyAccessor(entity);
237-
final CouchbasePersistentEntity<?> persistentEntity = mappingContext
234+
public Object getId(Object entity) {
235+
ConvertingPropertyAccessor<Object> accessor = getPropertyAccessor(entity);
236+
CouchbasePersistentEntity<?> persistentEntity = mappingContext
238237
.getRequiredPersistentEntity(entity.getClass());
239-
final CouchbasePersistentProperty idProperty = persistentEntity.getIdProperty();
238+
CouchbasePersistentProperty idProperty = persistentEntity.getIdProperty();
240239
Object id = null;
241240
if (idProperty != null) {
242241
id = accessor.getProperty(idProperty);
243242
}
244243
return id;
245244
}
246245

247-
public String getJavaNameForEntity(final Class<?> clazz) {
248-
final CouchbasePersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(clazz);
246+
public String getJavaNameForEntity(Class<?> clazz) {
247+
CouchbasePersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(clazz);
249248
MappingCouchbaseEntityInformation<?, Object> info = new MappingCouchbaseEntityInformation<>(persistentEntity);
250249
return info.getJavaType().getName();
251250
}
252251

253-
<T> ConvertingPropertyAccessor<T> getPropertyAccessor(final T source) {
252+
<T> ConvertingPropertyAccessor<T> getPropertyAccessor(T source) {
254253
CouchbasePersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(source.getClass());
255254
PersistentPropertyAccessor<T> accessor = entity.getPropertyAccessor(source);
256255
return new ConvertingPropertyAccessor<>(accessor, converter.getConversionService());

0 commit comments

Comments
 (0)