Class Collections
- java.lang.Object
-
- com.thebuzzmedia.exiftool.commons.iterables.Collections
-
public final class Collections extends Object
Static Collection Utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> void
addAll(Collection<T> collection, Iterable<T> iterable)
Add all elements of given iterable structure to given collection.static <T> boolean
isEmpty(Collection<T> values)
Check if collection is empty (null
or empty).static <T> boolean
isNotEmpty(Collection<T> values)
Check if collection is not empty (notnull
and not empty).static <T> String
join(Collection<T> values, String separator)
Join elements of collection to a final string.static <T,U>
List<U>map(Collection<T> inputs, Mapper<T,U> mapper)
Map list of inputs to a new list of outputs.static <T> int
size(Collection<T> values)
Get size of collection.static <T> Collection<T>
toCollection(Iterable<T> iterables)
Create in memory collection from given iterable elements.
-
-
-
Method Detail
-
isEmpty
public static <T> boolean isEmpty(Collection<T> values)
Check if collection is empty (null
or empty).- Type Parameters:
T
- Type of element in collection.- Parameters:
values
- Collection of values.- Returns:
true
if collection is empty (null
or empty),false
otherwise.
-
isNotEmpty
public static <T> boolean isNotEmpty(Collection<T> values)
Check if collection is not empty (notnull
and not empty).- Type Parameters:
T
- Type of element in collection.- Parameters:
values
- Collection of values.- Returns:
true
if collection is not empty (notnull
and not empty),false
otherwise.
-
size
public static <T> int size(Collection<T> values)
Get size of collection. If collection is empty (null or empty), zero will be returned.- Type Parameters:
T
- Type of element in collection.- Parameters:
values
- Collection of values.- Returns:
- Size of collection.
-
toCollection
public static <T> Collection<T> toCollection(Iterable<T> iterables)
Create in memory collection from given iterable elements.- If
iterables
is null, an empty array list is returned. - If
iterables
is already an instance ofCollection
, it is returned. - Otherwise, iterable structure is iterated and loaded into an
ArrayList
.
- Type Parameters:
T
- Type of element in iterable structure.- Parameters:
iterables
- Given iterable.- Returns:
- The collection result.
- If
-
join
public static <T> String join(Collection<T> values, String separator)
Join elements of collection to a final string. If collection is empty (null or empty), an empty string is returned.- Type Parameters:
T
- Type of element in collection.- Parameters:
values
- Collection of values.separator
- Separator, use to separate each elements.- Returns:
- Final string.
-
map
public static <T,U> List<U> map(Collection<T> inputs, Mapper<T,U> mapper)
Map list of inputs to a new list of outputs.- Type Parameters:
T
- Type of input.U
- Type of output.- Parameters:
inputs
- Input list.mapper
- Mapper used to transform inputs.- Returns:
- New list of outputs.
-
addAll
public static <T> void addAll(Collection<T> collection, Iterable<T> iterable)
Add all elements of given iterable structure to given collection.- Type Parameters:
T
- Type of elements.- Parameters:
collection
- The collection.iterable
- The iterable structure.
-
-