public class

Lists

extends Object
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.collect.Lists

Class Overview

Collection of utility functions to create of manipulate concrete or abstract lists.

Summary

Public Constructors
Lists()
Public Methods
static <T> void add(List<T> list, int index, T elt, T def)
Add (insert) the element of a collection.
static <T> List<T> add(List<T> dst, List<T> src)
static <T> void add(List<T> list, int index, T elt)
Add (insert) the element of a collection.
static <T> List<T> addNonNulls(List<T> dst, T... elts)
static <T> List<T> addNonNulls(List<T> dst, List<? extends T> src)
static <T extends Comparable<T>> int addSorted(List<T> sortedList, T elt)
Insert an element into a sorted list at its natural position.
static <T> ArrayList<T> createArrayList(T elt)
static <T> ArrayList<T> createArrayList(Collection...<? extends T> colls)
static <T> ArrayList<T> createArrayList()
static <T> T get(List<? extends T> list, int index, T safeValue)
Get the value of a list, safely returning a providing default value if the list s null or the index out-of-range.
static <T> T get(List<? extends T> list, int index)
Get the value of a list, safely returning null if the list is null or the index out-of-range.
static <T> T getFirst(List<? extends T> list)
Get the first value of a list, safely returning null if the list is null or the index out-of-range.
static <T, R> List<? extends R> map(Collection<T> input, Function<? super T, ? extends R> mapper)
Apply a 1-to-1 map operation to the elements of a collection and return the list of resulting new elements.
static <T> List<T> reverse(List<T> list)
Reverse the provided input list.
static <T> ListIterator<T> reverseIterator(List<T> list)
Get a reverse iterator on the list.
static <T> List<T> safe(List<T> list)
static <T> T set(List<T> list, int index, T elt)
Set the element of a collection.
static <T> T set(List<T> list, int index, T elt, T def)
Set the element of a collection.
static <T> List<T> subList(List<T> list, int fromIndex)
Get a tail sub-list of a list.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Lists ()

Public Methods

public static void add (List<T> list, int index, T elt, T def)

Add (insert) the element of a collection. If the index is negative, the method throws OOB. If it is greater that the current number of elements in the list, additional elements are inserted using the provided default value.

public static List<T> add (List<T> dst, List<T> src)

public static void add (List<T> list, int index, T elt)

Add (insert) the element of a collection. If the index is negative, the method throws OOB. If it is greater that the current number of elements in the list, additional elements are inserted using the null default value.

public static List<T> addNonNulls (List<T> dst, T... elts)

public static List<T> addNonNulls (List<T> dst, List<? extends T> src)

public static int addSorted (List<T> sortedList, T elt)

Insert an element into a sorted list at its natural position.

Parameters
sortedList a sorted (natural sort) list of comparable elements
elt the element to be inserted
Returns
  • the insertion index

public static ArrayList<T> createArrayList (T elt)

public static ArrayList<T> createArrayList (Collection...<? extends T> colls)

public static ArrayList<T> createArrayList ()

public static T get (List<? extends T> list, int index, T safeValue)

Get the value of a list, safely returning a providing default value if the list s null or the index out-of-range.

public static T get (List<? extends T> list, int index)

Get the value of a list, safely returning null if the list is null or the index out-of-range.

public static T getFirst (List<? extends T> list)

Get the first value of a list, safely returning null if the list is null or the index out-of-range.

public static List<? extends R> map (Collection<T> input, Function<? super T, ? extends R> mapper)

Apply a 1-to-1 map operation to the elements of a collection and return the list of resulting new elements.

Parameters
input input collection
mapper a map() function
Returns
  • output list

public static List<T> reverse (List<T> list)

Reverse the provided input list.

Parameters
list a list
Returns
  • the input list (same object), reversed

public static ListIterator<T> reverseIterator (List<T> list)

Get a reverse iterator on the list. The pointer is set to the last element of the list (if any).

public static List<T> safe (List<T> list)

Parameters
list input list, null
Returns
  • the input list or an empty list if the input was null

public static T set (List<T> list, int index, T elt)

Set the element of a collection. If the index is negative, the method throws OOB. If it is greater or equal than the current number of elements in the list, additional elements are inserted using the null default value.

public static T set (List<T> list, int index, T elt, T def)

Set the element of a collection. If the index is negative, the method throws OOB. If it is greater or equal than the current number of elements in the list, additional elements are inserted using the provided default value.

public static List<T> subList (List<T> list, int fromIndex)

Get a tail sub-list of a list.