Skip to content

Commit

Permalink
Remove java stream api and build sql when execute addAssignment method (
Browse files Browse the repository at this point in the history
  • Loading branch information
strongduanmu authored Nov 24, 2023
1 parent 309d6f3 commit 93fc8a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
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

0 comments on commit 93fc8a5

Please sign in to comment.