@Override
  public String getDisplayString(String[] children) {
    assert (children.length >= 2);
    StringBuilder sb = new StringBuilder();
    sb.append("CASE");
    for (int i = 0; i + 1 < children.length; i += 2) {
      sb.append(" WHEN (");
      sb.append(children[i]);
      sb.append(") THEN (");
      sb.append(children[i + 1]);
      sb.append(")");
    }
    if (children.length % 2 == 1) {
      sb.append(" ELSE (");
      sb.append(children[children.length - 1]);
      sb.append(")");
    }
    sb.append(" END");
    return sb.toString();
  }
GenericUDF Class for SQL construct
"CASE WHEN a THEN b WHEN c THEN d [ELSE f] END".

NOTES: 1. a and c should be boolean, or an exception will be thrown. 2. b, d
and f should be common types, or an exception will be thrown.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFWhen.java