code: @NullSafe
    @SuppressWarnings("unchecked")
    public static <T> T[] toArray(Collection<T> collection, Class<T> componentType) {
  
      Object[] array = (Object[]) Array.newInstance(componentType, nullSafeSize(collection));
  
      Optional.ofNullable(collection).ifPresent(localCollection -> collection.toArray(array));
  
      return (T[]) array;
    }
docs: Null-safe utility method to get any array for the given {@link Collection}.
  
  @param <T> {@link Class} type of the elements in the {@link Collection}.
  @param collection {@link Collection} to convert into an array.
  @param componentType {@link Class} type of the elements in the array.
  @return an array for the given {@link Collection}.  If the {@link Collection} is {@literal null}
  then an empty array of the {@link Class component type} is returned.