Skip to content

Commit 1d3a485

Browse files
mipo256mp911de
authored andcommitted
Polishing.
See: #359 Original pull request: #1385
1 parent cd444b2 commit 1d3a485

File tree

5 files changed

+14
-31
lines changed

5 files changed

+14
-31
lines changed

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/AsyncCassandraTemplate.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,10 @@ private int getEffectivePageSize(Statement<?> statement) {
865865
return statement.getPageSize();
866866
}
867867

868-
if (getAsyncCqlOperations() instanceof CassandraAccessor) {
868+
if (getAsyncCqlOperations() instanceof CassandraAccessor accessor) {
869869

870-
CassandraAccessor accessor = (CassandraAccessor) getAsyncCqlOperations();
871-
872-
if (accessor.getFetchSize() != -1) {
873-
return accessor.getFetchSize();
870+
if (accessor.getPageSize() != -1) {
871+
return accessor.getPageSize();
874872
}
875873
}
876874
class GetConfiguredPageSize implements AsyncSessionCallback<Integer>, CqlProvider {

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraTemplate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ protected <E extends CassandraMappingEvent<T>, T> void maybeEmitEvent(Supplier<E
961961
protected <T> T maybeCallBeforeConvert(T object, CqlIdentifier tableName) {
962962

963963
if (null != entityCallbacks) {
964-
return (T) entityCallbacks.callback(BeforeConvertCallback.class, object, tableName);
964+
return entityCallbacks.callback(BeforeConvertCallback.class, object, tableName);
965965
}
966966

967967
return object;
@@ -970,7 +970,7 @@ protected <T> T maybeCallBeforeConvert(T object, CqlIdentifier tableName) {
970970
protected <T> T maybeCallBeforeSave(T object, CqlIdentifier tableName, Statement<?> statement) {
971971

972972
if (null != entityCallbacks) {
973-
return (T) entityCallbacks.callback(BeforeSaveCallback.class, object, tableName, statement);
973+
return entityCallbacks.callback(BeforeSaveCallback.class, object, tableName, statement);
974974
}
975975

976976
return object;

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/StatementFactory.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ public StatementBuilder<RegularInsert> insert(Object objectToInsert, WriteOption
296296

297297
boolean insertNulls;
298298

299-
if (options instanceof InsertOptions) {
300-
301-
InsertOptions insertOptions = (InsertOptions) options;
299+
if (options instanceof InsertOptions insertOptions) {
302300
insertNulls = insertOptions.isInsertNulls();
303301
} else {
304302
insertNulls = false;
@@ -879,9 +877,7 @@ static Insert addWriteOptions(Insert insert, WriteOptions writeOptions) {
879877

880878
Assert.notNull(insert, "Insert must not be null");
881879

882-
if (writeOptions instanceof InsertOptions) {
883-
884-
InsertOptions insertOptions = (InsertOptions) writeOptions;
880+
if (writeOptions instanceof InsertOptions insertOptions) {
885881

886882
if (insertOptions.isIfNotExists()) {
887883
insert = insert.ifNotExists();
@@ -910,9 +906,7 @@ static com.datastax.oss.driver.api.querybuilder.update.Update addWriteOptions(
910906
com.datastax.oss.driver.api.querybuilder.update.Update updateToUse = QueryOptionsUtil.addWriteOptions(update,
911907
writeOptions);
912908

913-
if (writeOptions instanceof UpdateOptions) {
914-
915-
UpdateOptions updateOptions = (UpdateOptions) writeOptions;
909+
if (writeOptions instanceof UpdateOptions updateOptions) {
916910

917911
if (updateOptions.isIfExists()) {
918912
updateToUse = updateToUse.ifExists();
@@ -936,9 +930,7 @@ static Delete addWriteOptions(Delete delete, WriteOptions writeOptions) {
936930

937931
Delete deleteToUse = QueryOptionsUtil.addWriteOptions(delete, writeOptions);
938932

939-
if (writeOptions instanceof DeleteOptions) {
940-
941-
DeleteOptions deleteOptions = (DeleteOptions) writeOptions;
933+
if (writeOptions instanceof DeleteOptions deleteOptions) {
942934

943935
if (deleteOptions.isIfExists()) {
944936
deleteToUse = deleteToUse.where().ifExists();

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverter.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ public void setUserTypeResolver(UserTypeResolver userTypeResolver) {
232232
* @since 3.0
233233
*/
234234
public UserTypeResolver getUserTypeResolver() {
235+
235236
return this.userTypeResolver != null ? this.userTypeResolver : getMappingContext().getUserTypeResolver();
236237
}
237238

@@ -256,14 +257,8 @@ public ColumnTypeResolver getColumnTypeResolver() {
256257
* @see org.springframework.data.cassandra.core.mapping.CassandraPersistentEntity
257258
*/
258259
@SuppressWarnings("unchecked")
259-
private <S> ConvertingPropertyAccessor<S> newConvertingPropertyAccessor(S source,
260-
CassandraPersistentEntity<?> entity) {
261-
PersistentPropertyAccessor<S> propertyAccessor = source instanceof PersistentPropertyAccessor
262-
? (PersistentPropertyAccessor<S>) source
263-
: entity.getPropertyAccessor(source);
264-
265-
return new ConvertingPropertyAccessor<>(propertyAccessor, getConversionService());
266-
260+
private <S> ConvertingPropertyAccessor<S> newConvertingPropertyAccessor(S source, CassandraPersistentEntity<?> entity) {
261+
return new ConvertingPropertyAccessor<>(entity.getPropertyAccessor(source), getConversionService());
267262
}
268263

269264
private <S> CassandraPersistentEntityParameterValueProvider newParameterValueProvider(ConversionContext context,

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/SchemaFactory.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ public CreateTableSpecification getCreateTableSpecificationFor(CassandraPersiste
146146

147147
if (property.isCompositePrimaryKey()) {
148148

149-
CassandraPersistentEntity<?> primaryKeyEntity = mappingContext
150-
.getRequiredPersistentEntity(property.getRawType());
149+
CassandraPersistentEntity<?> primaryKeyEntity = mappingContext.getRequiredPersistentEntity(property.getRawType());
151150

152151
for (CassandraPersistentProperty primaryKeyProperty : primaryKeyEntity) {
153152

@@ -406,9 +405,8 @@ public void attach(@edu.umd.cs.findbugs.annotations.NonNull AttachmentPoint atta
406405
public boolean equals(@Nullable Object o) {
407406
if (this == o)
408407
return true;
409-
if (!(o instanceof com.datastax.oss.driver.api.core.type.UserDefinedType))
408+
if (!(o instanceof UserDefinedType that))
410409
return false;
411-
com.datastax.oss.driver.api.core.type.UserDefinedType that = (com.datastax.oss.driver.api.core.type.UserDefinedType) o;
412410
return isFrozen() == that.isFrozen() && Objects.equals(getName(), that.getName());
413411
}
414412

0 commit comments

Comments
 (0)