diff --git a/reactor-core/src/main/java/reactor/util/function/Tuple2.java b/reactor-core/src/main/java/reactor/util/function/Tuple2.java index 816edb5db9..d504f391bb 100644 --- a/reactor-core/src/main/java/reactor/util/function/Tuple2.java +++ b/reactor-core/src/main/java/reactor/util/function/Tuple2.java @@ -85,23 +85,37 @@ public Object get(int index) { } /** - * Turn this {@literal Tuples} into a plain Object list. + * Turn this {@code Tuple} into a {@link List List<Object>}. + * The list isn't tied to this Tuple but is a copy with limited + * mutability ({@code add} and {@code remove} are not supported, but {@code set} is). * - * @return A new Object list. + * @return A copy of the tuple as a new {@link List List<Object>}. */ public List toList() { return Arrays.asList(toArray()); } /** - * Turn this {@literal Tuples} into a plain Object array. + * Turn this {@code Tuple} into a plain {@code Object[]}. + * The array isn't tied to this Tuple but is a copy. * - * @return A new Object array. + * @return A copy of the tuple as a new {@link Object Object[]}. */ public Object[] toArray() { return new Object[]{t1, t2}; } + /** + * Return an immutable {@link Iterator Iterator<Object>} around + * the content of this {@code Tuple}. + * + * @implNote As an {@link Iterator} is always tied to its {@link Iterable} source by + * definition, the iterator cannot be mutable without the iterable also being mutable. + * Since {@link Tuples} are immutable, so is the {@link Iterator} + * returned by this method. + * + * @return An unmodifiable {@link Iterator} over the elements in this Tuple. + */ @Override public Iterator iterator() { return Collections.unmodifiableList(toList()).iterator();