code: @SuppressWarnings("unchecked")
      static <T> T[] getEnumConstants(Class<T> enm) {
          return Stream.of(enm.getFields())
                  .filter(f -> f.getType() == enm)
                  .map(f -> {
              try {
                  return f.get(null);
              } catch (Exception e) {
                  return null;
              }
          })
          .filter(Objects::nonNull)
          .toArray(len -> (T[]) Array.newInstance(enm, len));
      }
docs: Manually create enum values array without using enum.values().
  @param enm enum class to query
  @return array of enum values