Skip to content

Commit

Permalink
Minor refactoring.
Browse files Browse the repository at this point in the history
Original pull request #1895
  • Loading branch information
ngocnhan-tran1996 authored and schauder committed Sep 24, 2024
1 parent a1f2297 commit dc2e14c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
import static java.time.ZoneId.*;

import java.sql.Timestamp;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Period;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public <T> BiFunction<Row, RowMetadata, T> populateIdIfNecessary(T object) {

Object id = propertyAccessor.getProperty(idProperty);
if (idProperty.getType().isPrimitive()) {
idPropertyUpdateNeeded = id instanceof Number && ((Number) id).longValue() == 0;
idPropertyUpdateNeeded = id instanceof Number number && number.longValue() == 0;
} else {
idPropertyUpdateNeeded = id == null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ public static PreparedOperation<String> substituteNamedParameters(ParsedSql pars
}
k++;
Object entryItem = entryIter.next();
if (entryItem instanceof Object[]) {
Object[] expressionList = (Object[]) entryItem;
if (entryItem instanceof Object[] expressionList) {
actualSql.append('(');
for (int m = 0; m < expressionList.length; m++) {
if (m > 0) {
Expand Down Expand Up @@ -520,8 +519,7 @@ public void bind(org.springframework.r2dbc.core.binding.BindTarget target, Strin

Object valueToBind = iterator.next();

if (valueToBind instanceof Object[]) {
Object[] objects = (Object[]) valueToBind;
if (valueToBind instanceof Object[] objects) {
for (Object object : objects) {
bind(target, markers, object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ public void forEach(BiConsumer<? super SqlIdentifier, ? super Parameter> action)
}

private static Object convertKeyIfNecessary(Object key) {
return key instanceof String ? SqlIdentifier.unquoted((String) key) : key;
return key instanceof String string ? SqlIdentifier.unquoted(string) : key;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static <T> Mono<Page<T>> getPage(List<T> content, Pageable pageable, Mono
return totalSupplier.map(total -> new PageImpl<>(content, pageable, total));
}

if (content.size() != 0 && pageable.getPageSize() > content.size()) {
if (!content.isEmpty() && pageable.getPageSize() > content.size()) {
return Mono.just(new PageImpl<>(content, pageable, pageable.getOffset() + content.size()));
}

Expand Down

0 comments on commit dc2e14c

Please sign in to comment.