class UdafUtil {

  public static AggregateFunctionInitArguments createAggregateFunctionInitArgs(
      final int udafIndex, final FunctionCall functionCall
  ) {
    final List<Expression> args = functionCall.getArguments();

    final List<Object> initArgs = new ArrayList<>(Math.max(0, args.size() - 1));

    // args for index > 0 must be literals:
    for (int idx = 1; idx < args.size(); idx++) {
      final Expression param = args.get(idx);
      if (!(param instanceof Literal)) {
        throw new KsqlException("Parameter " + (idx + 1) + " passed to function "
            + functionCall.getName().text()
            + " must be a literal constant, but was expression: '" + param + "'");
      }

      initArgs.add(((Literal) param).getValue());
    }

    return new AggregateFunctionInitArguments(udafIndex, initArgs);
  }

  private  UdafUtil();

}