code: private static <T> T[] newEnumMap(Class<?> elementType,
                                        Function<SessionProtocol, T> factory,
                                        SessionProtocol... allowedProtocols) {
          @SuppressWarnings("unchecked")
          final T[] maps = (T[]) Array.newInstance(elementType, SessionProtocol.values().length);
          // Attempting to access the array with an unallowed protocol will trigger NPE,
          // which will help us find a bug.
          for (SessionProtocol p : allowedProtocols) {
              maps[p.ordinal()] = factory.apply(p);
          }
          return maps;
      }
docs: Returns an array whose index signifies {@link SessionProtocol#ordinal()}. Similar to {@link EnumMap}.