Skip to content

Commit

Permalink
cleanup: wrap -> wrapExceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Calum Murray <cmurray@redhat.com>
  • Loading branch information
Cali0707 committed Jun 19, 2024
1 parent dd7fee5 commit cfcff87
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 17 deletions.
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 comments on commit cfcff87

Please sign in to comment.