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

Remove java stream api and build sql when execute addAssignment method #29199

Merged
merged 1 commit into from
Nov 24, 2023
Merged
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 @@ -161,7 +161,7 @@ private EncryptAssignmentToken generateValuesSQLToken(final EncryptTable encrypt
} else if (likeQueryColumn.isPresent() != valueLikeQueryColumn.isPresent()) {
throw new UnsupportedEncryptSQLException(String.format("%s=VALUES(%s)", column, valueColumn));
}
if (result.getAssignment().isEmpty()) {
if (result.isAssignmentsEmpty()) {
throw new UnsupportedEncryptSQLException(String.format("%s=VALUES(%s)", column, valueColumn));
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

import java.util.Collection;
import java.util.LinkedList;
import java.util.stream.Collectors;

/**
* Function assignment token for encrypt.
*/
public final class EncryptFunctionAssignmentToken extends EncryptAssignmentToken {

private final StringBuilder builder = new StringBuilder();

private final Collection<FunctionAssignment> assignments = new LinkedList<>();

public EncryptFunctionAssignmentToken(final int startIndex, final int stopIndex) {
Expand All @@ -41,20 +42,23 @@ public EncryptFunctionAssignmentToken(final int startIndex, final int stopIndex)
* @param value assignment value
*/
public void addAssignment(final String columnName, final Object value) {
assignments.add(new FunctionAssignment(columnName, value));
FunctionAssignment functionAssignment = new FunctionAssignment(columnName, value);
assignments.add(functionAssignment);
builder.append(functionAssignment).append(", ");
}

/**
* Get assignments.
* @return FunctionAssignment collection
* Judge whether assignments is empty or not.
*
* @return whether assignments is empty or not
*/
public Collection<FunctionAssignment> getAssignment() {
return assignments;
public boolean isAssignmentsEmpty() {
return assignments.isEmpty();
}

@Override
public String toString() {
return assignments.stream().map(FunctionAssignment::toString).collect(Collectors.joining(", "));
return builder.substring(0, builder.length() - 2);
}

@RequiredArgsConstructor
Expand Down