Polishing.

See: #359
Original pull request: #1385
This commit is contained in:
Mikhail2048
2023-05-30 16:32:03 +03:00
committed by Mark Paluch
parent cd444b2286
commit 1d3a4856e9
5 changed files with 14 additions and 31 deletions

View File

@@ -865,12 +865,10 @@ public class AsyncCassandraTemplate
return statement.getPageSize();
}
if (getAsyncCqlOperations() instanceof CassandraAccessor) {
if (getAsyncCqlOperations() instanceof CassandraAccessor accessor) {
CassandraAccessor accessor = (CassandraAccessor) getAsyncCqlOperations();
if (accessor.getFetchSize() != -1) {
return accessor.getFetchSize();
if (accessor.getPageSize() != -1) {
return accessor.getPageSize();
}
}
class GetConfiguredPageSize implements AsyncSessionCallback<Integer>, CqlProvider {

View File

@@ -961,7 +961,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
protected <T> T maybeCallBeforeConvert(T object, CqlIdentifier tableName) {
if (null != entityCallbacks) {
return (T) entityCallbacks.callback(BeforeConvertCallback.class, object, tableName);
return entityCallbacks.callback(BeforeConvertCallback.class, object, tableName);
}
return object;
@@ -970,7 +970,7 @@ public class CassandraTemplate implements CassandraOperations, ApplicationEventP
protected <T> T maybeCallBeforeSave(T object, CqlIdentifier tableName, Statement<?> statement) {
if (null != entityCallbacks) {
return (T) entityCallbacks.callback(BeforeSaveCallback.class, object, tableName, statement);
return entityCallbacks.callback(BeforeSaveCallback.class, object, tableName, statement);
}
return object;

View File

@@ -296,9 +296,7 @@ public class StatementFactory {
boolean insertNulls;
if (options instanceof InsertOptions) {
InsertOptions insertOptions = (InsertOptions) options;
if (options instanceof InsertOptions insertOptions) {
insertNulls = insertOptions.isInsertNulls();
} else {
insertNulls = false;
@@ -879,9 +877,7 @@ public class StatementFactory {
Assert.notNull(insert, "Insert must not be null");
if (writeOptions instanceof InsertOptions) {
InsertOptions insertOptions = (InsertOptions) writeOptions;
if (writeOptions instanceof InsertOptions insertOptions) {
if (insertOptions.isIfNotExists()) {
insert = insert.ifNotExists();
@@ -910,9 +906,7 @@ public class StatementFactory {
com.datastax.oss.driver.api.querybuilder.update.Update updateToUse = QueryOptionsUtil.addWriteOptions(update,
writeOptions);
if (writeOptions instanceof UpdateOptions) {
UpdateOptions updateOptions = (UpdateOptions) writeOptions;
if (writeOptions instanceof UpdateOptions updateOptions) {
if (updateOptions.isIfExists()) {
updateToUse = updateToUse.ifExists();
@@ -936,9 +930,7 @@ public class StatementFactory {
Delete deleteToUse = QueryOptionsUtil.addWriteOptions(delete, writeOptions);
if (writeOptions instanceof DeleteOptions) {
DeleteOptions deleteOptions = (DeleteOptions) writeOptions;
if (writeOptions instanceof DeleteOptions deleteOptions) {
if (deleteOptions.isIfExists()) {
deleteToUse = deleteToUse.where().ifExists();

View File

@@ -232,6 +232,7 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
* @since 3.0
*/
public UserTypeResolver getUserTypeResolver() {
return this.userTypeResolver != null ? this.userTypeResolver : getMappingContext().getUserTypeResolver();
}
@@ -256,14 +257,8 @@ public class MappingCassandraConverter extends AbstractCassandraConverter
* @see org.springframework.data.cassandra.core.mapping.CassandraPersistentEntity
*/
@SuppressWarnings("unchecked")
private <S> ConvertingPropertyAccessor<S> newConvertingPropertyAccessor(S source,
CassandraPersistentEntity<?> entity) {
PersistentPropertyAccessor<S> propertyAccessor = source instanceof PersistentPropertyAccessor
? (PersistentPropertyAccessor<S>) source
: entity.getPropertyAccessor(source);
return new ConvertingPropertyAccessor<>(propertyAccessor, getConversionService());
private <S> ConvertingPropertyAccessor<S> newConvertingPropertyAccessor(S source, CassandraPersistentEntity<?> entity) {
return new ConvertingPropertyAccessor<>(entity.getPropertyAccessor(source), getConversionService());
}
private <S> CassandraPersistentEntityParameterValueProvider newParameterValueProvider(ConversionContext context,

View File

@@ -146,8 +146,7 @@ public class SchemaFactory {
if (property.isCompositePrimaryKey()) {
CassandraPersistentEntity<?> primaryKeyEntity = mappingContext
.getRequiredPersistentEntity(property.getRawType());
CassandraPersistentEntity<?> primaryKeyEntity = mappingContext.getRequiredPersistentEntity(property.getRawType());
for (CassandraPersistentProperty primaryKeyProperty : primaryKeyEntity) {
@@ -406,9 +405,8 @@ public class SchemaFactory {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (!(o instanceof com.datastax.oss.driver.api.core.type.UserDefinedType))
if (!(o instanceof UserDefinedType that))
return false;
com.datastax.oss.driver.api.core.type.UserDefinedType that = (com.datastax.oss.driver.api.core.type.UserDefinedType) o;
return isFrozen() == that.isFrozen() && Objects.equals(getName(), that.getName());
}