Top Constructors Methods
com.rometools.utils

public final Class Lists

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <T> List<T>

Returns:

List containing the given item
create
(final T
The item to add to the new list
item
)

Creates a new List with the given item as the first entry.

public static <T> List<T>

Returns:

The input list when it is not null, a new list otherwise
createWhenNull
(final List<T>
The list to process, can be null
list
)

Returns the list when it is not null.

public static <T> List<T>

Returns:

null when the list is empty or null, the given list otherwise
emptyToNull
(final List<T>
The list to process
list
)

Returns null, when the given list is empty or null

public static <T> T

Returns:

The first entry of the list when it is not null or empty, null otherwise
firstEntry
(final List<T>
The list to extract the first entry from, can be null
list
)

Extracts the first entry of the list when it is not null and contains values.

public static boolean

Returns:

true when the list is null or empty, false otherwise
isEmpty
(final List<?>
The list to check
list
)

Checks whether the list is null or empty.

public static boolean

Returns:

true when the list is not null and not empty
isNotEmpty
(final List<?>
The list to check
list
)

Checks whether the list is not null and not empty.

public static boolean

Returns:

true when the list has the given size or when size = 0 and the list is null, false otherwise
sizeIs
(final List<?>
The list to check
list
,
final int
The size to check
size
)

Checks whether the list has the given size.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Listsback to summary
private Lists()

Method Detail

createback to summary
public static <T> List<T> create(final T item)

Creates a new List with the given item as the first entry.

Parameters
item:T

The item to add to the new list

Returns:List<T>

List containing the given item

createWhenNullback to summary
public static <T> List<T> createWhenNull(final List<T> list)

Returns the list when it is not null. Returns a new list otherwise.

Parameters
list:List<T>

The list to process, can be null

Returns:List<T>

The input list when it is not null, a new list otherwise

emptyToNullback to summary
public static <T> List<T> emptyToNull(final List<T> list)

Returns null, when the given list is empty or null

Parameters
list:List<T>

The list to process

Returns:List<T>

null when the list is empty or null, the given list otherwise

firstEntryback to summary
public static <T> T firstEntry(final List<T> list)

Extracts the first entry of the list when it is not null and contains values.

Parameters
list:List<T>

The list to extract the first entry from, can be null

Returns:T

The first entry of the list when it is not null or empty, null otherwise

isEmptyback to summary
public static boolean isEmpty(final List<?> list)

Checks whether the list is null or empty.

Parameters
list:List<?>

The list to check

Returns:boolean

true when the list is null or empty, false otherwise

isNotEmptyback to summary
public static boolean isNotEmpty(final List<?> list)

Checks whether the list is not null and not empty.

Parameters
list:List<?>

The list to check

Returns:boolean

true when the list is not null and not empty

sizeIsback to summary
public static boolean sizeIs(final List<?> list, final int size)

Checks whether the list has the given size. A null list is treated like a list without entries.

Parameters
list:List<?>

The list to check

size:int

The size to check

Returns:boolean

true when the list has the given size or when size = 0 and the list is null, false otherwise