Class Lists
java.lang.Object
org.glassfish.jersey.internal.guava.Lists
Static utility methods pertaining to
List
instances. Also see this
class's counterparts Sets
, Maps
and Queues
.
See the Guava User Guide article on
Lists
.
- Since:
- 2.0 (imported from Google Collections Library)
- Author:
- Kevin Bourrillion, Mike Bostock, Louis Wasserman
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> ArrayList<E>
newArrayList
(Iterable<? extends E> elements) Creates a mutableArrayList
instance containing the given elements; a very thin shortcut for creating an empty list then callingIterables#addAll
.static <E> ArrayList<E>
newArrayList
(Iterator<? extends E> elements) Creates a mutableArrayList
instance containing the given elements; a very thin shortcut for creating an empty list and then callingIterators.addAll(java.util.Collection<T>, java.util.Iterator<? extends T>)
.
-
Method Details
-
newArrayList
Creates a mutableArrayList
instance containing the given elements; a very thin shortcut for creating an empty list then callingIterables#addAll
.Note: if mutability is not required and the elements are non-null, use
ImmutableList#copyOf(Iterable)
instead. (Or, changeelements
to be aFluentIterable
and callelements.toList()
.)Note for Java 7 and later: if
elements
is aCollection
, you don't need this method. Use theArrayList
constructor directly, taking advantage of the new "diamond" syntax. -
newArrayList
Creates a mutableArrayList
instance containing the given elements; a very thin shortcut for creating an empty list and then callingIterators.addAll(java.util.Collection<T>, java.util.Iterator<? extends T>)
.Note: if mutability is not required and the elements are non-null, use
ImmutableList#copyOf(Iterator)
instead.
-