private Optional<OutputEvent> coerceReturnValue(InvocationContext ctx, MethodWrapper method, Object rawResult) { try { return Optional.of((ctx.getRuntimeContext()).getOutputCoercions(method.getTargetMethod()) .stream() .map((c) -> c.wrapFunctionResult(ctx, method, rawResult)) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new FunctionOutputHandlingException("No coercion found for return type"))); } catch (RuntimeException e) { throw new FunctionOutputHandlingException("An exception was thrown during Output Coercion: " + e.getMessage(), e); } }
protected Optional<OutputEvent> coerceReturnValue(InvocationContext ctx, MethodWrapper method, Object rawResult) { try { return Optional.of(ctx.getRuntimeContext().getOutputCoercions(method.getTargetMethod()) .stream() .map((c) -> c.wrapFunctionResult(ctx, method, rawResult)) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new FunctionOutputHandlingException("No coercion found for return type"))); } catch (RuntimeException e) { throw new FunctionOutputHandlingException("An exception was thrown during Output Coercion: " + e.getMessage(), e); } }