This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 14f568723d5 Remove Optional parameter and useless
EncryptColumnsMergedResultFixture (#19915)
14f568723d5 is described below
commit 14f568723d5e491fd4a0020f51f2bd4496439ed3
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Sat Aug 6 07:53:11 2022 +0800
Remove Optional parameter and useless EncryptColumnsMergedResultFixture
(#19915)
---
.../DecoratedEncryptShowColumnsMergedResult.java | 2 +-
.../EncryptInsertValueParameterRewriter.java | 10 ++---
.../EncryptPredicateRightValueTokenGenerator.java | 12 ++++--
.../fixture/EncryptColumnsMergedResultFixture.java | 44 ----------------------
4 files changed, 15 insertions(+), 53 deletions(-)
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResult.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResult.java
index b73dbcc1809..e2aec390c81 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResult.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/DecoratedEncryptShowColumnsMergedResult.java
@@ -30,7 +30,7 @@ public final class DecoratedEncryptShowColumnsMergedResult
extends EncryptShowCo
private final MergedResult mergedResult;
- public DecoratedEncryptShowColumnsMergedResult(final MergedResult
mergedResult, final SQLStatementContext sqlStatementContext, final EncryptRule
encryptRule) {
+ public DecoratedEncryptShowColumnsMergedResult(final MergedResult
mergedResult, final SQLStatementContext<?> sqlStatementContext, final
EncryptRule encryptRule) {
super(sqlStatementContext, encryptRule);
this.mergedResult = mergedResult;
}
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
index 1d68903cf6c..24382f889fc 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/parameter/rewriter/EncryptInsertValueParameterRewriter.java
@@ -69,12 +69,12 @@ public final class EncryptInsertValueParameterRewriter
implements ParameterRewri
String columnName = descendingColumnNames.next();
EncryptContext encryptContext =
EncryptContextBuilder.build(databaseName, schemaName, tableName, columnName);
encryptRule.findEncryptor(tableName,
columnName).ifPresent(optional -> encryptInsertValues((GroupedParameterBuilder)
parameterBuilder, insertStatementContext, optional,
- encryptRule.findAssistedQueryEncryptor(tableName,
columnName), encryptContext));
+ encryptRule.findAssistedQueryEncryptor(tableName,
columnName).orElse(null), encryptContext));
}
}
private void encryptInsertValues(final GroupedParameterBuilder
parameterBuilder, final InsertStatementContext insertStatementContext,
- final EncryptAlgorithm<?, ?>
encryptAlgorithm, final Optional<EncryptAlgorithm> assistEncryptAlgorithm,
final EncryptContext encryptContext) {
+ final EncryptAlgorithm<?, ?>
encryptAlgorithm, final EncryptAlgorithm<?, ?> assistEncryptAlgorithm, final
EncryptContext encryptContext) {
int columnIndex = getColumnIndex(parameterBuilder,
insertStatementContext, encryptContext.getColumnName());
int count = 0;
for (List<Object> each :
insertStatementContext.getGroupedParameters()) {
@@ -105,14 +105,14 @@ public final class EncryptInsertValueParameterRewriter
implements ParameterRewri
}
@SuppressWarnings({"rawtypes", "unchecked"})
- private void encryptInsertValue(final EncryptAlgorithm encryptAlgorithm,
final Optional<EncryptAlgorithm> assistEncryptor, final int parameterIndex,
+ private void encryptInsertValue(final EncryptAlgorithm encryptAlgorithm,
final EncryptAlgorithm assistEncryptor, final int parameterIndex,
final Object originalValue, final
StandardParameterBuilder parameterBuilder, final EncryptContext encryptContext)
{
parameterBuilder.addReplacedParameters(parameterIndex,
encryptAlgorithm.encrypt(originalValue, encryptContext));
Collection<Object> addedParameters = new LinkedList<>();
- if (assistEncryptor.isPresent()) {
+ if (null != assistEncryptor) {
Optional<String> assistedColumnName =
encryptRule.findAssistedQueryColumn(encryptContext.getTableName(),
encryptContext.getColumnName());
Preconditions.checkArgument(assistedColumnName.isPresent(), "Can
not find assisted query Column Name");
- addedParameters.add(assistEncryptor.get().encrypt(originalValue,
encryptContext));
+ addedParameters.add(assistEncryptor.encrypt(originalValue,
encryptContext));
}
if (encryptRule.findPlainColumn(encryptContext.getTableName(),
encryptContext.getColumnName()).isPresent()) {
addedParameters.add(originalValue);
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
index 65a929006bc..5be3fa299fd 100644
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
+++
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/EncryptPredicateRightValueTokenGenerator.java
@@ -45,7 +45,13 @@ import java.util.Optional;
* Predicate right value token generator for encrypt.
*/
@Setter
-public final class EncryptPredicateRightValueTokenGenerator implements
CollectionSQLTokenGenerator, ParametersAware, EncryptConditionsAware,
EncryptRuleAware, DatabaseNameAware {
+public final class EncryptPredicateRightValueTokenGenerator
+ implements
+ CollectionSQLTokenGenerator<SQLStatementContext<?>>,
+ ParametersAware,
+ EncryptConditionsAware,
+ EncryptRuleAware,
+ DatabaseNameAware {
private List<Object> parameters;
@@ -56,12 +62,12 @@ public final class EncryptPredicateRightValueTokenGenerator
implements Collectio
private String databaseName;
@Override
- public boolean isGenerateSQLToken(final SQLStatementContext
sqlStatementContext) {
+ public boolean isGenerateSQLToken(final SQLStatementContext<?>
sqlStatementContext) {
return sqlStatementContext instanceof WhereAvailable &&
!((WhereAvailable) sqlStatementContext).getWhereSegments().isEmpty();
}
@Override
- public Collection<SQLToken> generateSQLTokens(final SQLStatementContext
sqlStatementContext) {
+ public Collection<SQLToken> generateSQLTokens(final SQLStatementContext<?>
sqlStatementContext) {
Collection<SQLToken> result = new LinkedHashSet<>();
String schemaName =
sqlStatementContext.getTablesContext().getSchemaName().orElseGet(() ->
DatabaseTypeEngine.getDefaultSchemaName(sqlStatementContext.getDatabaseType(),
databaseName));
for (EncryptCondition each : encryptConditions) {
diff --git
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/fixture/EncryptColumnsMergedResultFixture.java
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/fixture/EncryptColumnsMergedResultFixture.java
deleted file mode 100644
index 05a86fd787b..00000000000
---
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/fixture/EncryptColumnsMergedResultFixture.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.encrypt.merge.dql.fixture;
-
-import
org.apache.shardingsphere.encrypt.merge.dal.show.EncryptShowColumnsMergedResult;
-import org.apache.shardingsphere.encrypt.rule.EncryptRule;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-
-public final class EncryptColumnsMergedResultFixture extends
EncryptShowColumnsMergedResult {
-
- public EncryptColumnsMergedResultFixture(final SQLStatementContext
sqlStatementContext, final EncryptRule encryptRule) {
- super(sqlStatementContext, encryptRule);
- }
-
- @Override
- public boolean nextValue() {
- return false;
- }
-
- @Override
- public Object getOriginalValue(final int columnIndex, final Class<?> type)
{
- return null;
- }
-
- @Override
- public boolean wasNull() {
- return false;
- }
-}