mirror of
https://gitee.com/agents-flex/agents-flex.git
synced 2024-11-29 18:38:17 +08:00
refactor: refactor ExpressionAdaptor
This commit is contained in:
parent
8a39182a6f
commit
e0189217af
@ -24,7 +24,7 @@ public interface ExpressionAdaptor {
|
||||
|
||||
default String toCondition(Condition condition) {
|
||||
return toLeft(condition.left)
|
||||
+ toSymbol(condition.type)
|
||||
+ toOperationSymbol(condition.type)
|
||||
+ toRight(condition.right);
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public interface ExpressionAdaptor {
|
||||
return operand.toExpression(this);
|
||||
}
|
||||
|
||||
default String toSymbol(ConditionType type) {
|
||||
default String toOperationSymbol(ConditionType type) {
|
||||
return type.getDefaultSymbol();
|
||||
}
|
||||
|
||||
@ -67,7 +67,6 @@ public interface ExpressionAdaptor {
|
||||
return connector.getValue();
|
||||
}
|
||||
|
||||
|
||||
default String toGroupStart(Group group) {
|
||||
return "(";
|
||||
}
|
||||
|
@ -27,24 +27,22 @@ public class MilvusExpressionAdaptor implements ExpressionAdaptor {
|
||||
public static final MilvusExpressionAdaptor DEFAULT = new MilvusExpressionAdaptor();
|
||||
|
||||
@Override
|
||||
public String toSymbol(ConditionType type) {
|
||||
public String toOperationSymbol(ConditionType type) {
|
||||
if (type == ConditionType.EQ) {
|
||||
return " == ";
|
||||
}
|
||||
|
||||
return ExpressionAdaptor.super.toSymbol(type);
|
||||
return type.getDefaultSymbol();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toCondition(Condition condition) {
|
||||
if (condition.getType() == ConditionType.BETWEEN) {
|
||||
Object[] values = (Object[]) ((Value) condition.getRight()).getValue();
|
||||
return "(" + toLeft(condition.getLeft())
|
||||
+ toSymbol(ConditionType.GE)
|
||||
+ toOperationSymbol(ConditionType.GE)
|
||||
+ values[0] + " && "
|
||||
+ toLeft(condition.getLeft())
|
||||
+ toSymbol(ConditionType.LE)
|
||||
+ toOperationSymbol(ConditionType.LE)
|
||||
+ values[1] + ")";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user