class FunctionResolver {

    PartialFunction resolveFunction(String name, List<String> arguments) {
        int argumentSize = arguments.size();
        String argumentsRepresentation = join(", ", arguments);

        switch (argumentSize) {
            case 0:
                Function0 function0 = ensureNotNull(
                        zeroArgumentFunctions.get(name),
                        "No such function=[%s], with n=[%d] arguments=[%s]", name, argumentSize, argumentsRepresentation);
                return function0::call;
            case 1:
                Function1 function1 = ensureNotNull(
                        oneArgumentFunctions.get(name),
                        "No such function=[%s], with n=[%d] arguments=[%s]", name, argumentSize, argumentsRepresentation);
                return (request, context) -> function1.call(request, context, arguments.get(0));

            default:
                throw new IllegalArgumentException(format("No such function=[%s], with n=[%d] arguments=[%s]", name, argumentSize, argumentsRepresentation));
        }
    }

    public  FunctionResolver(Map<String, Function0> zeroArgumentFunctions, Map<String, Function1> oneArgumentFunctions);

}