com.jdroid.java.collections
Class Lists

java.lang.Object
  extended by com.jdroid.java.collections.Lists

public class Lists
extends Object


Constructor Summary
Lists()
           
 
Method Summary
static
<T> List<T>
filter(List<T> unfilteredList, Predicate<T> predicate)
           
static Boolean isNullOrEmpty(List<?> list)
           
static
<E> ArrayList<E>
newArrayList()
          Creates a mutable, empty ArrayList instance.
static
<E> ArrayList<E>
newArrayList(E... elements)
          Creates a mutable ArrayList instance containing the given elements.
static
<E> ArrayList<E>
newArrayList(Iterable<? extends E> elements)
          Creates a mutable ArrayList instance containing the given elements.
static
<E> ArrayList<E>
newArrayList(Iterator<? extends E> elements)
          Creates a mutable ArrayList instance containing the given elements.
static
<E> LinkedList<E>
newLinkedList()
          Creates an empty LinkedList instance.
static
<E> LinkedList<E>
newLinkedList(Iterable<? extends E> elements)
          Creates a LinkedList instance containing the given elements.
static
<E> List<E>
safeArrayList(List<E> list)
           
static
<T> List<T>
trim(List<T> list, int maxCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lists

public Lists()
Method Detail

newArrayList

public static <E> ArrayList<E> newArrayList()
Creates a mutable, empty ArrayList instance.

Returns:
a new, empty ArrayList

newArrayList

public static <E> ArrayList<E> newArrayList(E... elements)
Creates a mutable ArrayList instance containing the given elements.

Parameters:
elements - the elements that the list should contain, in order
Returns:
a new ArrayList containing those elements

safeArrayList

public static <E> List<E> safeArrayList(List<E> list)

newArrayList

public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements)
Creates a mutable ArrayList instance containing the given elements.

Parameters:
elements - the elements that the list should contain, in order
Returns:
a new ArrayList containing those elements

newArrayList

public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements)
Creates a mutable ArrayList instance containing the given elements.

Parameters:
elements - the elements that the list should contain, in order
Returns:
a new ArrayList containing those elements

newLinkedList

public static <E> LinkedList<E> newLinkedList()
Creates an empty LinkedList instance.

Returns:
a new, empty LinkedList

newLinkedList

public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements)
Creates a LinkedList instance containing the given elements.

Parameters:
elements - the elements that the list should contain, in order
Returns:
a new LinkedList containing those elements

trim

public static <T> List<T> trim(List<T> list,
                               int maxCount)
Parameters:
list -
maxCount -
Returns:
same list if size doesn't exceeds maxCount, new list with trimmed element otherwise

isNullOrEmpty

public static Boolean isNullOrEmpty(List<?> list)

filter

public static <T> List<T> filter(List<T> unfilteredList,
                                 Predicate<T> predicate)


Copyright © 2014. All rights reserved.