@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    for (int i = 0; i + 1 < arguments.length; i += 2) {
      Object caseKey = arguments[i].get();
      if (caseKey != null
          && ((BooleanObjectInspector) argumentOIs[i]).get(caseKey)) {
        Object caseValue = arguments[i + 1].get();
        return returnOIResolver.convertIfNecessary(caseValue,
            argumentOIs[i + 1]);
      }
    }
    // Process else statement
    if (arguments.length % 2 == 1) {
      int i = arguments.length - 2;
      Object elseValue = arguments[i + 1].get();
      return returnOIResolver.convertIfNecessary(elseValue, argumentOIs[i + 1]);
    }
    return null;
  }
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