8000 Cesql v1 fixes by Cali0707 · Pull Request #641 · cloudevents/sdk-java · GitHub
[go: up one dir, main page]

Skip to content

Cesql v1 fixes #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 21, 2024
Merged
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup: wrap -> wrapExceptions
Signed-off-by: Calum Murray <cmurray@redhat.com>
  • Loading branch information
Cali0707 committed Jun 19, 2024
commit cfcff8747e9759a919a6ee98c96c92d00afe3799
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.cloudevents.CloudEvent;
import io.cloudevents.sql.EvaluationRuntime;
import io.cloudevents.sql.ExceptionFactory;
import io.cloudevents.sql.Type;
import io.cloudevents.sql.impl.ExpressionInternal;
import io.cloudevents.sql.impl.runtime.EvaluationResult;
import org.antlr.v4.runtime.misc.Interval;
Expand All @@ -24,6 +23,6 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
}

EvaluationResult right = this.getRightOperand().evaluate(runtime, event, exceptionFactory);
return castToBoolean(exceptionFactory, right).wrap(left);
return castToBoolean(exceptionFactory, right).wrapExceptions(left);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.cloudevents.sql.EvaluationRuntime;
import io.cloudevents.sql.ExceptionFactory;
import io.cloudevents.sql.Type;
import io.cloudevents.sql.impl.ExceptionFactoryImpl;
import io.cloudevents.sql.impl.ExpressionInternal;
import io.cloudevents.sql.impl.runtime.EvaluationResult;
import org.antlr.v4.runtime.misc.Interval;
Expand All @@ -23,7 +22,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
EvaluationResult right = this.getRightOperand().evaluate(runtime, event, exceptionFactory);

if (left.isMissingAttributeException() || right.isMissingAttributeException()) {
return left.wrap(right).copyWithDefaultValueForType(Type.INTEGER);
return left.wrapExceptions(right).copyWithDefaultValueForType(Type.INTEGER);
}

EvaluationResult x = castToInteger(exceptionFactory, left);
Expand All @@ -34,7 +33,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
(Integer)x.value(),
(Integer)y.value(),
exceptionFactory
).wrap(x).wrap(y);
).wrapExceptions(x).wrapExceptions(y);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
EvaluationResult right = this.getRightOperand().evaluate(runtime, event, exceptionFactory);

if (left.isMissingAttributeException() || right.isMissingAttributeException()) {
return left.wrap(right).copyWithDefaultValueForType(Type.BOOLEAN);
return left.wrapExceptions(right).copyWithDefaultValueForType(Type.BOOLEAN);
}

left = TypeCastingProvider.cast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
runtime,
event,
computedArguments
).wrap(exceptions);
).wrapExceptions(exceptions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
if (Objects.equals(leftValue.value(), rightValue.value())) {
return new EvaluationResult(true, null, leftValue, rightValue);
} else {
leftValue.wrap(rightValue);
leftValue.wrapExceptions(rightValue);
}
}
return leftValue.copyWithValue(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import io.cloudevents.sql.EvaluationRuntime;
import io.cloudevents.sql.ExceptionFactory;
import io.cloudevents.sql.Type;
import io.cloudevents.sql.impl.ExceptionFactoryImpl;
import io.cloudevents.sql.impl.ExpressionInternal;
import io.cloudevents.sql.impl.runtime.EvaluationResult;
import org.antlr.v4.runtime.misc.Interval;
Expand Down Expand Up @@ -43,7 +42,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
EvaluationResult right = this.getRightOperand().evaluate(runtime, event, exceptionFactory);

if (left.isMissingAttributeException() || right.isMissingAttributeException()) {
return left.wrap(right).copyWithDefaultValueForType(Type.BOOLEAN);
return left.wrapExceptions(right).copyWithDefaultValueForType(Type.BOOLEAN);
}

EvaluationResult x = castToInteger(exceptionFactory, left);
Expand All @@ -52,7 +51,7 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
return new EvaluationResult(this.operation.evaluate(
(Integer)x.value(),
(Integer)y.value()
)).wrap(x).wrap(y);
)).wrapExceptions(x).wrapExceptions(y);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import io.cloudevents.CloudEvent;
import io.cloudevents.sql.EvaluationRuntime;
import io.cloudevents.sql.ExceptionFactory;
import io.cloudevents.sql.Type;
import io.cloudevents.sql.impl.ExceptionFactoryImpl;
import io.cloudevents.sql.impl.ExpressionInternal;
import io.cloudevents.sql.impl.runtime.EvaluationResult;
import org.antlr.v4.runtime.misc.Interval;
Expand All @@ -25,6 +23,6 @@ public EvaluationResult evaluate(EvaluationRuntime runtime, CloudEvent event, Ex
return new EvaluationResult(Boolean.logicalXor(
(Boolean)x.value(),
(Boolean)y.value()
)).wrap(x).wrap(y);
)).wrapExceptions(x).wrapExceptions(y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public EvaluationResult(Object value) {
this.latestException = null;
}

public EvaluationResult wrap(EvaluationResult other) {
public EvaluationResult wrapExceptions(EvaluationResult other) {
if (other != null && other.exceptions != null) {
return this.wrap(other.exceptions);
return this.wrapExceptions(other.exceptions);
}
return this;
}

public EvaluationResult wrap(List<EvaluationException> exceptions) {
public EvaluationResult wrapExceptions(List<EvaluationException> exceptions) {
if (!exceptions.isEmpty()) {
this.exceptions.addAll(exceptions);
}
Expand Down
0