class BeamSqlInitCapExpression extends BeamSqlStringUnaryExpression {

  @Override
  public BeamSqlPrimitive evaluate(
      Row inputRow, BoundedWindow window, ImmutableMap<Integer, Object> correlateEnv) {
    String str = opValueEvaluated(0, inputRow, window, correlateEnv);

    StringBuilder ret = new StringBuilder(str);
    boolean isInit = true;
    for (int i = 0; i < str.length(); i++) {
      if (Character.isWhitespace(str.charAt(i))) {
        isInit = true;
        continue;
      }

      if (isInit) {
        ret.setCharAt(i, Character.toUpperCase(str.charAt(i)));
        isInit = false;
      } else {
        ret.setCharAt(i, Character.toLowerCase(str.charAt(i)));
      }
    }
    return BeamSqlPrimitive.of(SqlTypeName.VARCHAR, ret.toString());
  }

  public  BeamSqlInitCapExpression(List<BeamSqlExpression> operands);

}