jfsii commented on a change in pull request #1119:
URL: https://github.com/apache/hive/pull/1119#discussion_r440522788



##########
File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
##########
@@ -101,6 +102,65 @@
   private volatile boolean isSparkConfigUpdated = false;
   private static final int LOG_PREFIX_LENGTH = 64;
 
+  interface HiveConfEnum<T extends Enum<T>> {
+    public static <T extends Enum<T>> T from(Class<T> cls, String value, T 
invalidEnum) {
+      try {
+        return T.valueOf(cls, value.toUpperCase());
+      } catch (Exception e) {
+        return invalidEnum;
+      }
+    }
+  }

Review comment:
       Should I even bother with this interface? The intent was originally to 
have static definitions of getValidSet and getInvalid as part of the interface 
in addition to from. Except Java interfaces don't allow implementations of an 
interface to override static methods. The from method here is also not super 
useful in that I think I still have to fully qualify the call (I.E. 
HiveConfEnum.from()). It would be nice if we could define required static 
methods on a enum interface for future uses of enums in HiveConf, but I don't 
think it is cleanly possible.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to