未验证 提交 cbd8aaa4 编写于 作者: L Liang Zhang 提交者: GitHub

code style for #4296 (#4301)

上级 236af2b0
......@@ -80,7 +80,7 @@ public final class EncryptConditionEngine {
}
return result;
}
private Collection<EncryptCondition> createEncryptConditions(final AndPredicate andPredicate, final TablesContext tablesContext) {
Collection<EncryptCondition> result = new LinkedList<>();
Collection<Integer> stopIndexes = new HashSet<>();
......
......@@ -48,8 +48,8 @@ import java.util.Map;
* @author zhangliang
*/
@Setter
public final class EncryptPredicateRightValueTokenGenerator extends BaseEncryptSQLTokenGenerator implements CollectionSQLTokenGenerator,
RelationMetasAware, ParametersAware, QueryWithCipherColumnAware {
public final class EncryptPredicateRightValueTokenGenerator extends BaseEncryptSQLTokenGenerator
implements CollectionSQLTokenGenerator, RelationMetasAware, ParametersAware, QueryWithCipherColumnAware {
private RelationMetas relationMetas;
......
......@@ -36,23 +36,23 @@
<input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = 1 AND a.password = 'aaa' AND a.amount = 1000 AND a.status = 'OK'" />
<output sql="SELECT a.account_id, a.cipher_password, a.cipher_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.account_id = 1 AND a.assisted_query_password = 'assisted_query_aaa' AND a.cipher_amount = 'encrypt_1000' AND a.status = 'OK'" />
</rewrite-assertion>
<rewrite-assertion id="select_plain_for_parameters_with_in_has_no_left_space">
<input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.password in(?, ?) AND a.amount in (?, ?)" parameters="aaa, aaa, 1000, 1000" />
<output sql="SELECT a.account_id, a.cipher_password, a.cipher_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.assisted_query_password in(?, ?) AND a.cipher_amount in (?, ?)" parameters="assisted_query_aaa, assisted_query_aaa, encrypt_1000, encrypt_1000" />
</rewrite-assertion>
<rewrite-assertion id="select_plain_for_parameters_with_in_has_no_left_space_and_parameter_has_left_space">
<input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.password in( ?, ?) AND a.amount in (?, ?)" parameters="aaa, aaa, 1000, 1000" />
<output sql="SELECT a.account_id, a.cipher_password, a.cipher_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.assisted_query_password in(?, ?) AND a.cipher_amount in (?, ?)" parameters="assisted_query_aaa, assisted_query_aaa, encrypt_1000, encrypt_1000" />
</rewrite-assertion>
<rewrite-assertion id="select_plain_for_parameters_with_in_has_no_left_space_and_parameter_has_left_newline">
<input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.password in(
?, ?) AND a.amount in (?, ?)" parameters="aaa, aaa, 1000, 1000" />
<output sql="SELECT a.account_id, a.cipher_password, a.cipher_amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.assisted_query_password in(?, ?) AND a.cipher_amount in (?, ?)" parameters="assisted_query_aaa, assisted_query_aaa, encrypt_1000, encrypt_1000" />
</rewrite-assertion>
<rewrite-assertion id="select_plain_for_parameters_with_in_has_more_than_one_left_space_and_parameter_has_left_newline">
<input sql="SELECT a.account_id, a.password, a.amount AS a, a.status AS s FROM t_account_bak AS a WHERE a.password in (
?, ?) AND a.amount in (?, ?)" parameters="aaa, aaa, 1000, 1000" />
......
......@@ -18,28 +18,26 @@
package org.apache.shardingsphere.sql.parser.core.constant;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* Predicate in bracket.
*
* @author chun.yang
*/
@RequiredArgsConstructor
@Getter
public enum Bracket {
/**
* in left bracket.
* In left bracket.
*/
LEFT("("),
/**
* in right bracket.
* In right bracket.
*/
RIGHT(")");
private final String value;
Bracket(final String value) {
this.value = value;
}
}
......@@ -83,7 +83,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
}
return leftPredicate.isPresent() ? leftPredicate : rightPredicate;
}
private ParserRuleContext extractOperatorNode(final ParserRuleContext exprNode, final int childIndex) {
ParserRuleContext result = (ParserRuleContext) exprNode.getChild(childIndex);
while (ExtractorUtils.findFirstChildNodeNoneRecursive(result, RuleName.LOGICAL_OPERATOR).isPresent()) {
......@@ -91,7 +91,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
}
return result;
}
private Optional<OrPredicateSegment> extractPredicateSegment(final ParserRuleContext exprNode, final ParserRuleContext childNode,
final int childIndex, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
ParserRuleContext operatorNode = childNode;
......@@ -116,7 +116,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
}
return result;
}
private Optional<OrPredicateSegment> extractRecursiveWithParen(final ParserRuleContext exprNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
if (1 == exprNode.getChild(0).getText().length() && Paren.isLeftParen(exprNode.getChild(0).getText().charAt(0))) {
return extractRecursiveWithLogicalOperation((ParserRuleContext) exprNode.getChild(1), parameterMarkerIndexes);
......@@ -190,7 +190,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
predicateNode.getStart().getStartIndex(), predicateNode.getStop().getStopIndex(), column, new PredicateBetweenRightValue(betweenSQLExpression.get(), andSQLExpression.get())))
: Optional.<PredicateSegment>absent();
}
private Optional<PredicateSegment> extractInPredicate(final ParserRuleContext predicateNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes, final ColumnSegment column) {
Optional<PredicateBracketValue> predicateBracketValue = extractBracketValue(predicateNode);
Collection<ExpressionSegment> sqlExpressions = extractInExpressionSegments(predicateNode, parameterMarkerIndexes);
......@@ -198,7 +198,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
new PredicateInRightValue(predicateBracketValue.get(), sqlExpressions));
return sqlExpressions.isEmpty() ? Optional.<PredicateSegment>absent() : Optional.of(predicateSegment);
}
private Optional<PredicateBracketValue> extractBracketValue(final ParserRuleContext predicateNode) {
PredicateLeftBracketValue predicateLeftBracketValue = null;
PredicateRightBracketValue predicateRightBracketValue = null;
......@@ -215,7 +215,7 @@ public final class PredicateExtractor implements OptionalSQLSegmentExtractor {
}
return Optional.absent();
}
private Collection<ExpressionSegment> extractInExpressionSegments(final ParserRuleContext predicateNode, final Map<ParserRuleContext, Integer> parameterMarkerIndexes) {
List<ExpressionSegment> result = new LinkedList<>();
for (int i = 3; i < predicateNode.getChildCount(); i++) {
......
......@@ -27,8 +27,8 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@Getter
public final class PredicateBracketValue implements PredicateRightValue {
private final PredicateLeftBracketValue predicateLeftBracketValue;
private final PredicateRightBracketValue predicateRightBracketValue;
}
......@@ -31,8 +31,8 @@ import java.util.Collection;
@RequiredArgsConstructor
@Getter
public final class PredicateInRightValue implements PredicateRightValue {
private final PredicateBracketValue predicateBracketValue;
private final Collection<ExpressionSegment> sqlExpressions;
}
......@@ -30,8 +30,8 @@ import lombok.ToString;
@Getter
@ToString
public final class PredicateLeftBracketValue implements PredicateRightValue {
private final int startIndex;
private final int stopIndex;
}
......@@ -30,8 +30,8 @@ import lombok.ToString;
@Getter
@ToString
public final class PredicateRightBracketValue implements PredicateRightValue {
private final int startIndex;
private final int stopIndex;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册