private Object[] resolveActualInputs(EvaluationContext ctx, FEEL feel) { Map<String, Object> variables = ctx.getAllValues(); Object[] actualInputs = new Object[ inputs.size() ]; for( int i = 0; i < inputs.size(); i++ ) { CompiledExpression compiledInput = inputs.get( i ).getCompiledInput(); if( compiledInput != null ) { actualInputs[i] = feel.evaluate( compiledInput, variables ); } else { actualInputs[i] = feel.evaluate( inputs.get( i ).getInputExpression(), variables ); } } return actualInputs; }
/** * If valid input values are defined, check that all parameters match the respective valid inputs * @param ctx * @param params * @return */ private Either<FEELEvent, Object> actualInputsMatchInputValues(EvaluationContext ctx, Object[] params) { // check that all the parameters match the input list values if they are defined for( int i = 0; i < params.length; i++ ) { final DTInputClause input = inputs.get( i ); // if a list of values is defined, check the the parameter matches the value if ( input.getInputValues() != null && ! input.getInputValues().isEmpty() ) { final Object parameter = params[i]; boolean satisfies = input.getInputValues().stream().map( ut -> ut.apply( ctx, parameter ) ).filter( Boolean::booleanValue ).findAny().orElse( false ); if ( !satisfies ) { String values = input.getInputValuesText(); return Either.ofLeft(new InvalidInputEvent( FEELEvent.Severity.ERROR, input.getInputExpression()+"='" + parameter + "' does not match any of the valid values " + values + " for decision table '" + getName() + "'.", getName(), null, values ) ); } } } return Either.ofRight(true); }