Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pattern matching #1895

Closed
Closed
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 @@ -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
Loading