Comment pedantry.

Considered adding a note that toArray() is generally not safe, but the
Collections run through here in normal depot usage will be safe to use.
Check out the implementation of AbstractCollection's toArray(T[]).
This commit is contained in:
Ray Greenwell
2010-02-24 02:07:36 +00:00
parent 9444cad7d8
commit 17a6cb3332
@@ -65,6 +65,7 @@ public abstract class Sequence<T> implements Iterable<T>
} }
return list; return list;
} }
// In a perfect world this would be <S super T> S[] toArray (Class<S> clazz)
public T[] toArray (Class<T> clazz) { public T[] toArray (Class<T> clazz) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T[] array = (T[]) Array.newInstance(clazz, source.size()); T[] array = (T[]) Array.newInstance(clazz, source.size());
@@ -91,13 +92,13 @@ public abstract class Sequence<T> implements Iterable<T>
public abstract boolean isEmpty (); public abstract boolean isEmpty ();
/** /**
* Converts this sequence into an array list. * Converts this sequence into an ArrayList.
*/ */
public abstract ArrayList<T> toList (); public abstract ArrayList<T> toList ();
/** /**
* Converts this sequence into an array. * Converts this sequence into an array.
* I wish this were <S super T> S[] toArray (Class<S? clazz); * I wish this were <S super T> S[] toArray (Class<?> clazz);
*/ */
public abstract T[] toArray (Class<T> clazz); public abstract T[] toArray (Class<T> clazz);
} }