提交 82fa4ef2 编写于 作者: J Juergen Hoeller

Polishing

Issue: SPR-14863
上级 388e173b
......@@ -36,9 +36,9 @@ public class OpEQ extends Operator {
this.exitTypeDescriptor = "Z";
}
@Override
public BooleanTypedValue getValueInternal(ExpressionState state)
throws EvaluationException {
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
Object left = getLeftOperand().getValueInternal(state).getValue();
Object right = getRightOperand().getValueInternal(state).getValue();
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
......@@ -86,11 +86,9 @@ public class OpEQ extends Operator {
}
String operatorClassName = Operator.class.getName().replace('.', '/');
String evaluationContextClassName = EvaluationContext.class.getName().replace('.',
'/');
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck", "(L"
+ evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z",
false);
String evaluationContextClassName = EvaluationContext.class.getName().replace('.', '/');
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck",
"(L" + evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z", false);
cf.pushDescriptor("Z");
}
......
......@@ -37,9 +37,9 @@ public class OpNE extends Operator {
this.exitTypeDescriptor = "Z";
}
@Override
public BooleanTypedValue getValueInternal(ExpressionState state)
throws EvaluationException {
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
Object left = getLeftOperand().getValueInternal(state).getValue();
Object right = getRightOperand().getValueInternal(state).getValue();
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
......@@ -87,11 +87,9 @@ public class OpNE extends Operator {
}
String operatorClassName = Operator.class.getName().replace('.', '/');
String evaluationContextClassName = EvaluationContext.class.getName().replace('.',
'/');
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck", "(L"
+ evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z",
false);
String evaluationContextClassName = EvaluationContext.class.getName().replace('.', '/');
mv.visitMethodInsn(INVOKESTATIC, operatorClassName, "equalityCheck",
"(L" + evaluationContextClassName + ";Ljava/lang/Object;Ljava/lang/Object;)Z", false);
// Invert the boolean
Label notZero = new Label();
......
......@@ -159,6 +159,16 @@ public abstract class Operator extends SpelNodeImpl {
cf.pushDescriptor("Z");
}
/**
* Perform an equality check for the given operand values.
* <p>This method is not just used for reflective comparisons in subclasses
* but also from compiled expression code, which is why it needs to be
* declared as {@code public static} here.
* @param context the current evaluation context
* @param left the left-hand operand value
* @param right the right-hand operand value
*/
public static boolean equalityCheck(EvaluationContext context, Object left, Object right) {
if (left instanceof Number && right instanceof Number) {
Number leftNumber = (Number) left;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册