Class Lists

java.lang.Object
org.glassfish.jersey.internal.guava.Lists

public final class Lists extends Object
Static utility methods pertaining to List instances. Also see this class's counterparts Sets, Maps and
invalid reference
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 Details

    • newArrayList

      public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements)
      Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list then calling
      invalid reference
      Iterables#addAll
      .

      Note: if mutability is not required and the elements are non-null, use

      invalid reference
      ImmutableList#copyOf(Iterable)
      instead. (Or, change elements to be a
      invalid reference
      FluentIterable
      and call elements.toList().)

      Note for Java 7 and later: if elements is a Collection, you don't need this method. Use the ArrayList constructor directly, taking advantage of the new "diamond" syntax.

    • newArrayList

      public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
      Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list and then calling Iterators.addAll(Collection, Iterator).

      Note: if mutability is not required and the elements are non-null, use

      invalid reference
      ImmutableList#copyOf(Iterator)
      instead.