@SuppressWarnings("unchecked")
  // Safe unchecked as element is known to be of type E
  private static <E extends OrdinalValue<E>> ImmutableOrdinalSet<E> constructFromArray(OrdinalValue<?>[] array) {
    switch (array.length) {
    case 0:
      return of();
    case 1:
      // Safe unchecked as element is known to be of type E
      return new SingletonImmutableOrdinalSet<>((E) array[0]);
    default:
      return new RegularImmutableOrdinalSet<>(((E) array[0]).domain(), array);
    }
  }
Creates immutable ordinal set from array of elements.
All elements expected to have same {@link OrdinalValue#domain()} as the first element,
otherwise exception will be thrown.
@param <E> the element type
@param elements the elements, no nulls allowed
@return the immutable ordinal set
ordinal/src/org/immutables/ordinal/ImmutableOrdinalSet.java