static Object[] getAdjustedParametersForMethod(EvaluationContext ctx, Object[] params, boolean isNamedParams,
                                                   Method m) {
        logger.trace("getAdjustedParametersForMethod {} {} {} {}", ctx, params, isNamedParams, m);
        Object[] toReturn = addCtxParamIfRequired(ctx, params, isNamedParams, m);
        Class<?>[] parameterTypes = m.getParameterTypes();
        if (isNamedParams) {
            // This is inherently frail because it expects that, if, the first parameter is NamedParameter and the
            // function is a CustomFunction, then all parameters are NamedParameter
            NamedParameter[] namedParams =
                    Arrays.stream(toReturn).map(NamedParameter.class::cast).toArray(NamedParameter[]::new);
            toReturn = BaseFEELFunctionHelper.calculateActualParams(m, namedParams);
            if (toReturn == null) {
                // incompatible method
                return null;
            }
        } else if (toReturn.length > 0) {
            // if named parameters, then it has been adjusted already in the calculateActualParams method,
            // otherwise adjust here
            toReturn = adjustForVariableParameters(toReturn, parameterTypes);
        }
        toReturn = adjustByCoercion(parameterTypes, toReturn);
        return toReturn;
    }
@Test
    void getAdjustedParametersForMethod() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        // StddevFunction.invoke(@ParameterName( "list" ) List<?> list)
        Method method = StddevFunction.class.getMethod("invoke", List.class);
        assertNotNull(method);
        Object actualValue = Arrays.asList(2, 4, 7, 5);
        Object[] parameters = {new NamedParameter("list", actualValue)};

        Object[] retrieved = BaseFEELFunctionHelper.getAdjustedParametersForMethod(ctx, parameters, true, method);
        assertNotNull(retrieved);
        assertEquals(parameters.length, retrieved.length);
        assertEquals(actualValue, retrieved[0]);
    }