Skip to content
Closed

Polish #1912

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class IterableOfEntryToMapConverter implements ConditionalConverter, Converter<I

source.forEach(element -> {

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ private PreparedOperation<Insert> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class NamedParameterExpander {
/**
* Cache of original SQL String to ParsedSql representation.
*/
@SuppressWarnings("serial") private final Map<String, ParsedSql> parsedSqlCache = new LinkedHashMap<String, ParsedSql>(
@SuppressWarnings("serial") private final Map<String, ParsedSql> parsedSqlCache = new LinkedHashMap<>(
DEFAULT_CACHE_LIMIT, 0.75f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<String, ParsedSql> eldest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* </p>
*
*
* @param <T> type of the entity for which this represents a database interaction.
*/
final class DeleteRoot<T> implements DbAction<T> {
Expand Down Expand Up @@ -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.
* </p>
*
*
* @param <T> type of the entity for which this represents a database interaction.
*/
final class DeleteAllRoot<T> implements DbAction<T> {
Expand Down Expand Up @@ -467,7 +467,7 @@ interface WithDependingOn<T> extends WithPropertyPath<T>, WithEntity<T> {
* <p>
* Values come from parent entities but one might also add values manually.
* </p>
*
*
* @return guaranteed to be not {@code null}.
*/
Map<PersistentPropertyPath<RelationalPersistentProperty>, Object> getQualifiers();
Expand All @@ -479,7 +479,7 @@ interface WithDependingOn<T> extends WithPropertyPath<T>, WithEntity<T> {
default Pair<PersistentPropertyPath<RelationalPersistentProperty>, Object> getQualifier() {

Map<PersistentPropertyPath<RelationalPersistentProperty>, Object> qualifiers = getQualifiers();
if (qualifiers.size() == 0)
if (qualifiers.isEmpty())
return null;

if (qualifiers.size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

import org.springframework.data.relational.core.sql.IdentifierProcessing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
*/
record EmbeddedContext(RelationalPersistentProperty ownerProperty) {

EmbeddedContext {
}

public String getEmbeddedPrefix() {
return ownerProperty.getEmbeddedPrefix();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package org.springframework.data.relational.core.mapping.event;

import org.springframework.data.relational.core.conversion.AggregateChange;

import java.io.Serial;

/**
Expand All @@ -37,7 +35,7 @@
* <li>SQL statements get applied to the database.</li>
* <li>{@link AfterSaveCallback} and {@link AfterSaveEvent} get published.</li>
* </ol>
*
*
* @since 1.1
* @author Jens Schauder
* @author Mark Paluch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Loading