static Object[] adjustByCoercion(Class<?>[] parameterTypes, Object[] actualParams) {
        logger.trace("adjustByCoercion {} {}", parameterTypes, actualParams);
        Object[] toReturn = actualParams;
        int counter = Math.min(parameterTypes.length, actualParams.length);
        for (int i = 0; i < counter; i++) {
            Class<?> expectedParameterType = parameterTypes[i];
            Optional<Object[]> coercedParams;
            Object actualParam = actualParams[i];
            if (actualParam != null) {
                Class<?> currentIdxActualParameterType = actualParam.getClass();
                if (expectedParameterType.isAssignableFrom(currentIdxActualParameterType)) {
                    // not null object assignable to expected type: no need to coerce
                    coercedParams = Optional.of(toReturn);
                } else {
                    // attempt to coerce
                    coercedParams = coerceParams(currentIdxActualParameterType,
                                                 expectedParameterType, toReturn, i);
                }
            } else {
                // null object - no need to coerce
                coercedParams = Optional.of(toReturn);
            }
            if (coercedParams.isPresent()) {
                toReturn = coercedParams.get();
                continue;
            }
            return null;
        }
        return toReturn;
    }
@Test
    void adjustByCoercion() {
        // no coercion needed
        Object actualParam = List.of(true, false);
        Class<?>[] parameterTypes = new Class[]{List.class};
        Object[] actualParams = {actualParam};
        Object[] retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertEquals(actualParams, retrieved);

        actualParam = "StringA";
        parameterTypes = new Class[]{String.class};
        actualParams = new Object[]{actualParam};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertEquals(actualParams, retrieved);

        // coercing more objects to different types: fails
        parameterTypes = new Class[]{String.class, Integer.class};
        actualParams = new Object[]{"String", 34 };
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertEquals(actualParams, retrieved);

        // not coercing null value to not-list type
        actualParam = null;
        actualParams = new Object[]{actualParam};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertEquals(actualParams, retrieved);

        // not coercing null value to singleton list
        parameterTypes = new Class[]{List.class};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertEquals(actualParams, retrieved);

        // coercing not-null value to singleton list
        actualParam = "StringA";
        actualParams = new Object[]{actualParam};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertNotNull(retrieved);
        assertNotEquals(actualParams, retrieved);
        assertEquals(1, retrieved.length);
        assertNotNull(retrieved[0]);
        assertThat(retrieved[0]).isInstanceOf(List.class);
        List retrievedList = (List) retrieved[0];
        assertEquals(1, retrievedList.size());
        assertEquals(actualParam, retrievedList.get(0));

        // coercing null value to array: fails
        parameterTypes = new Class[]{Object.class.arrayType()};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertNull(retrieved);

        // coercing one object to different type: fails
        actualParam = 45;
        parameterTypes = new Class[]{String.class};
        actualParams = new Object[]{actualParam};
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertNull(retrieved);

        // coercing more objects to different types: fails
        parameterTypes = new Class[]{String.class, Integer.class};
        actualParams = new Object[]{"String", "34" };
        retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
        assertNull(retrieved);

    }