public static <I, O> @NotNull List<O> toUnmodifiableList(final @NotNull Function<I, O> mapper, final @NotNull Iterable<? extends I> source) {
    final ArrayList<O> ret = source instanceof Collection<?> ? new ArrayList<>(((Collection<?>) source).size()) : new ArrayList<>();
    for (final I el : source) {
      ret.add(requireNonNull(mapper.apply(requireNonNull(el, "source[?]")), "mapper(source[?])"));
    }
    return Collections.unmodifiableList(ret);
  }
Create a list eagerly mapping the source elements through the {@code mapper function}.

<p>All elements must be non-null before and after mapping.</p>

@param <I>    the input type
@param <O>    the output type
@param mapper element mapper
@param source input elements
@return a mapped list
@since 4.15.0
api/src/main/java/net/kyori/adventure/util/MonkeyBars.java