diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java index ad72d6392c7..f53843d4a78 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IterableOfEntryToMapConverter.java @@ -41,12 +41,12 @@ class IterableOfEntryToMapConverter implements ConditionalConverter, Converter { - if (!(element instanceof Entry)) { - throw new IllegalArgumentException(String.format("Cannot convert %s to Map.Entry", element.getClass())); + if (element instanceof Entry entry) { + result.put(entry.getKey(), entry.getValue()); + return; } - Entry entry = (Entry) element; - result.put(entry.getKey(), entry.getValue()); + throw new IllegalArgumentException(String.format("Cannot convert %s to Map.Entry", element.getClass())); }); return result; diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcColumnTypes.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcColumnTypes.java index 77d7ed88d82..e1649c0fc3d 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcColumnTypes.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcColumnTypes.java @@ -20,7 +20,6 @@ import java.time.OffsetDateTime; import java.time.ZonedDateTime; import java.time.temporal.Temporal; -import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java index 255ed7fa738..bdbdc9267aa 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcIdentifierBuilder.java @@ -16,7 +16,6 @@ package org.springframework.data.jdbc.core.convert; import org.springframework.data.relational.core.mapping.AggregatePath; -import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java index e38e5c02d74..451b5dc386e 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java @@ -296,7 +296,7 @@ private Condition mapCondition(CriteriaDefinition criteria, MapSqlParameterSourc && metadataBackedField.property != null // && (criteria.getValue() == null || !criteria.getValue().getClass().isArray())) { - RelationalPersistentProperty property = ((MetadataBackedField) propertyField).property; + RelationalPersistentProperty property = metadataBackedField.property; JdbcValue jdbcValue = convertToJdbcValue(property, criteria.getValue()); mappedValue = jdbcValue.getValue(); sqlType = jdbcValue.getJdbcType() != null ? jdbcValue.getJdbcType() : propertyField.getSqlType(); diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentProperty.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentProperty.java index 1b926536f75..9f3b3bc3ff8 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentProperty.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentProperty.java @@ -20,7 +20,6 @@ import org.springframework.data.mapping.model.SimpleTypeHolder; import org.springframework.data.relational.core.mapping.BasicRelationalPersistentProperty; import org.springframework.data.relational.core.mapping.NamingStrategy; -import org.springframework.data.relational.core.mapping.RelationalMappingContext; import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; /** diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/JdbcMappingContext.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/JdbcMappingContext.java index b4fb17600f7..3e8de438277 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/JdbcMappingContext.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/JdbcMappingContext.java @@ -15,8 +15,6 @@ */ package org.springframework.data.jdbc.core.mapping; -import org.springframework.data.mapping.InstanceCreatorMetadata; -import org.springframework.data.mapping.Parameter; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.model.Property; import org.springframework.data.mapping.model.SimpleTypeHolder; @@ -25,8 +23,6 @@ import org.springframework.data.relational.core.mapping.RelationalPersistentEntity; import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; import org.springframework.data.util.TypeInformation; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; /** * {@link MappingContext} implementation for JDBC. diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java index 08d4eb4f464..732c38f4f1f 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/SimpleJdbcRepository.java @@ -31,7 +31,6 @@ import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.FluentQuery; import org.springframework.data.repository.query.QueryByExampleExecutor; -import org.springframework.data.util.Streamable; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; diff --git a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/DefaultStatementMapper.java b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/DefaultStatementMapper.java index c8010b09a27..75e217f7304 100644 --- a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/DefaultStatementMapper.java +++ b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/DefaultStatementMapper.java @@ -172,8 +172,7 @@ private PreparedOperation getMappedObject(InsertSpec insertSpec, for (Assignment assignment : boundAssignments.getAssignments()) { - if (assignment instanceof AssignValue) { - AssignValue assignValue = (AssignValue) assignment; + if (assignment instanceof AssignValue assignValue) { insertBuilder.column(assignValue.getColumn()); withBuild = insertBuilder.value(assignValue.getValue()); diff --git a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterExpander.java b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterExpander.java index 375444e0464..a41f732bee0 100644 --- a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterExpander.java +++ b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterExpander.java @@ -54,7 +54,7 @@ class NamedParameterExpander { /** * Cache of original SQL String to ParsedSql representation. */ - @SuppressWarnings("serial") private final Map parsedSqlCache = new LinkedHashMap( + @SuppressWarnings("serial") private final Map parsedSqlCache = new LinkedHashMap<>( DEFAULT_CACHE_LIMIT, 0.75f, true) { @Override protected boolean removeEldestEntry(Map.Entry eldest) { diff --git a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterUtils.java b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterUtils.java index 287d8d71f9a..e98a17cd17d 100644 --- a/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterUtils.java +++ b/spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/core/NamedParameterUtils.java @@ -384,11 +384,11 @@ int getEndIndex() { public boolean equals(@Nullable Object o) { if (this == o) return true; - if (!(o instanceof ParameterHolder)) - return false; - ParameterHolder that = (ParameterHolder) o; - return this.startIndex == that.startIndex && this.endIndex == that.endIndex + if (o instanceof ParameterHolder that) { + return this.startIndex == that.startIndex && this.endIndex == that.endIndex && Objects.equals(this.parameterName, that.parameterName); + } + return false; } @Override diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java index a0ccf16c6a4..28699c3bdae 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/conversion/DbAction.java @@ -209,7 +209,7 @@ public String toString() { * Note that deletes for contained entities that reference the root are to be represented by separate * {@link DbAction}s. *

- * + * * @param type of the entity for which this represents a database interaction. */ final class DeleteRoot implements DbAction { @@ -274,7 +274,7 @@ public String toString() { * Note that deletes for contained entities that reference the root are to be represented by separate * {@link DbAction}s. *

- * + * * @param type of the entity for which this represents a database interaction. */ final class DeleteAllRoot implements DbAction { @@ -467,7 +467,7 @@ interface WithDependingOn extends WithPropertyPath, WithEntity { *

* Values come from parent entities but one might also add values manually. *

- * + * * @return guaranteed to be not {@code null}. */ Map, Object> getQualifiers(); @@ -479,7 +479,7 @@ interface WithDependingOn extends WithPropertyPath, WithEntity { default Pair, Object> getQualifier() { Map, Object> qualifiers = getQualifiers(); - if (qualifiers.size() == 0) + if (qualifiers.isEmpty()) return null; if (qualifiers.size() > 1) { diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/MariaDbDialect.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/MariaDbDialect.java index 69459c4f60f..4387724134c 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/MariaDbDialect.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/MariaDbDialect.java @@ -17,7 +17,6 @@ import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import org.springframework.data.relational.core.sql.IdentifierProcessing; diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/EmbeddedContext.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/EmbeddedContext.java index 52062da2290..9374cf03818 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/EmbeddedContext.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/EmbeddedContext.java @@ -23,9 +23,6 @@ */ record EmbeddedContext(RelationalPersistentProperty ownerProperty) { - EmbeddedContext { - } - public String getEmbeddedPrefix() { return ownerProperty.getEmbeddedPrefix(); } diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/InsertOnlyProperty.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/InsertOnlyProperty.java index 08402743e69..4614a668dbc 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/InsertOnlyProperty.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/InsertOnlyProperty.java @@ -17,7 +17,6 @@ import java.lang.annotation.Documented; import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertEvent.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertEvent.java index 6dfe99d0ea7..ec2e9a98b11 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertEvent.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/event/BeforeConvertEvent.java @@ -15,8 +15,6 @@ */ package org.springframework.data.relational.core.mapping.event; -import org.springframework.data.relational.core.conversion.AggregateChange; - import java.io.Serial; /** @@ -37,7 +35,7 @@ *
  • SQL statements get applied to the database.
  • *
  • {@link AfterSaveCallback} and {@link AfterSaveEvent} get published.
  • * - * + * * @since 1.1 * @author Jens Schauder * @author Mark Paluch diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectStatementVisitor.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectStatementVisitor.java index 2fecbd47e36..24916d3e8e1 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectStatementVisitor.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/render/SelectStatementVisitor.java @@ -101,9 +101,7 @@ public Delegation doEnter(Visitable segment) { @Override public Delegation doLeave(Visitable segment) { - if (segment instanceof Select) { - - Select select = (Select) segment; + if (segment instanceof Select select) { builder.append("SELECT "); diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/CriteriaFactory.java b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/CriteriaFactory.java index b1db189bf51..1281b03b183 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/CriteriaFactory.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/repository/query/CriteriaFactory.java @@ -23,7 +23,6 @@ import org.springframework.data.relational.core.sql.Expression; import org.springframework.data.repository.query.parser.Part; import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; /**