Skip to content

Polish #1912

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

Closed
wants to merge 4 commits into from
Closed

Polish #1912

Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Polish pattern matching usage
  • Loading branch information
ngocnhan-tran1996 committed Oct 11, 2024
commit 5df7a6af2fb72e7416ffd370972cc21a9fff3d91
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 @@ -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 @@ -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 @@ -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 @@ -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