Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
See: #359
Original pull request: #1385
  • Loading branch information
mipo256 authored and mp911de committed Jun 7, 2023
1 parent cd444b2 commit 1d3a485
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,10 @@ private int getEffectivePageSize(Statement<?> statement) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ protected <E extends CassandraMappingEvent<T>, T> void maybeEmitEvent(Supplier<E
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;
Expand All @@ -970,7 +970,7 @@ protected <T> T maybeCallBeforeConvert(T object, CqlIdentifier tableName) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ public StatementBuilder<RegularInsert> insert(Object objectToInsert, WriteOption

boolean insertNulls;

if (options instanceof InsertOptions) {

InsertOptions insertOptions = (InsertOptions) options;
if (options instanceof InsertOptions insertOptions) {
insertNulls = insertOptions.isInsertNulls();
} else {
insertNulls = false;
Expand Down Expand Up @@ -879,9 +877,7 @@ static Insert addWriteOptions(Insert insert, WriteOptions writeOptions) {

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();
Expand Down Expand Up @@ -910,9 +906,7 @@ static com.datastax.oss.driver.api.querybuilder.update.Update addWriteOptions(
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();
Expand All @@ -936,9 +930,7 @@ static Delete addWriteOptions(Delete delete, WriteOptions writeOptions) {

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public void setUserTypeResolver(UserTypeResolver userTypeResolver) {
* @since 3.0
*/
public UserTypeResolver getUserTypeResolver() {

return this.userTypeResolver != null ? this.userTypeResolver : getMappingContext().getUserTypeResolver();
}

Expand All @@ -256,14 +257,8 @@ public ColumnTypeResolver getColumnTypeResolver() {
* @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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ public CreateTableSpecification getCreateTableSpecificationFor(CassandraPersiste

if (property.isCompositePrimaryKey()) {

CassandraPersistentEntity<?> primaryKeyEntity = mappingContext
.getRequiredPersistentEntity(property.getRawType());
CassandraPersistentEntity<?> primaryKeyEntity = mappingContext.getRequiredPersistentEntity(property.getRawType());

for (CassandraPersistentProperty primaryKeyProperty : primaryKeyEntity) {

Expand Down Expand Up @@ -406,9 +405,8 @@ public void attach(@edu.umd.cs.findbugs.annotations.NonNull AttachmentPoint atta
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());
}

Expand Down

0 comments on commit 1d3a485

Please sign in to comment.