Github user paul-rogers commented on the issue:

    https://github.com/apache/drill/pull/1021
  
    @arina-ielchiieva, it helps to think about the source of the enum. This is 
a Protobuf enum. The ordinal values cannot change; they are a contract between 
sender and receiver. We can add new ones, or retire old ones, but otherwise the 
values are frozen in time.
    
    The array approach captures this reality. We could document the array 
better:
    ```
    String displayNames[] = {
      "First Value", // FIRST_VALUE = 0
      "Second Value", // SECOND_VALUE = 1
      ...
    };
    ```
    We can also do a bounds check:
    ```
    if (enumValue.ordinal() >= displayNames.length) {
      return enumValue.toString();
    else
      return displayNames[enumValue.ordinal());
    }
    ```
    But, IMHO a map seems overkill for such a simple task. Yes, it works, but 
is unnecessary. As they say, "make it as simple as possible (but no simpler)."


---

Reply via email to