Functions: FnList

1. Overview

FnList is a parameterizable function hub class and, before giving you access to the real functions, you will have to specify the type parameter, which will give you access to the functions containing the operations on Lists:

FnListOf

The functions in FnListOf are applied on Lists. FnListOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnList.ofBigDecimal(), FnList.ofLong(), FnList.of(final Type<T> type), ...).

FnList.of(final Type<T> type) is the most generic method that gives you access to FnListOf though there are some shortcuts for common classes: FnList.ofBigDecimal(), FnList.ofInteger(), FnList.ofDate(), FnList.ofCharacter(), ...

The examples below show how these functions can be used:

/* This piece of code converts the Strings into Calendar and sorts them */        
Op.onListFor("2000/11/10", "2010/10/10", "2000/01/10")
	.forEach().exec(FnString.toCalendar("yyyy/MM/dd")).endFor()
	.exec(FnList.ofCalendar().sort()).get();
	
/* This piece of code creates the map {first = [23], second = [2.3], third = [-23.456]} */        
Op.onListFor(BigDecimal.valueOf(23), BigDecimal.valueOf(2.3), BigDecimal.valueOf(-23.456))
	.exec(FnList.ofBigDecimal().zipAndGroupKeys("first", "second", "third")).get();
	
/* This piece of code creates the map {ff0000 = red, 00ff00 = green, 0000ff = blue} */	
Op.onListFor("ff0000", "red", "00ff00", "green", "0000ff", "blue")
	.exec(FnList.ofString().couple()).get();
Function nameTypeParamsDescription
addFunction<List<T>,List<T>>T... newElements
addAllFunction<List<T>,List<T>>Collection<T> collection
allFunction<List<T>,Boolean>IFunction<? super T,Boolean> eval
anyFunction<List<T>,Boolean>IFunction<? super T,Boolean> eval
containsFunction<List<T>,Boolean>T object
containsAllFunction<List<T>,Boolean>T... objects
containsAnyFunction<List<T>,Boolean>T... objects
containsNoneFunction<List<T>,Boolean>T... objects
countFunction<List<T>,Integer>
coupleFunction<List<T>,Map<T,T>>
coupleAndGroupFunction<List<T>,Map<T,List<T>>>
distinctFunction<List<T>,List<T>>
insertFunction<List<T>,List<T>>int position
T... newElements
notContainsFunction<List<T>,Boolean>T object
removeAllEqualFunction<List<T>,List<T>>T... values
removeAllFalseFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
removeAllIndexesFunction<List<T>,List<T>>int... indexes
removeAllIndexesNotFunction<List<T>,List<T>>int... indexes
removeAllNotNullAndFalseFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
removeAllNotNullAndTrueFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
removeAllNullFunction<List<T>,List<T>>
removeAllNullOrFalseFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
removeAllNullOrTrueFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
removeAllTrueFunction<List<T>,List<T>>IFunction<? super T,Boolean> eval
reverseFunction<List<T>,List<T>>
sortFunction<List<T>,List<T>>
sortFunction<List<T>,List<T>>Comparator<? super T> comparator
sortByFunction<List<T>,List<T>>IFunction<? super T, ?> by
toArrayFunction<List<T>,T[]>
toGroupMapFunction<List<T>,Map<K,List<V>>>IFunction<? super T,Map.Entry<K,V>> mapBuilder
toGroupMapFunction<List<T>,Map<K,List<V>>>IFunction<? super T,K> keyFunction
IFunction<? super T,V> valueFunction
toMapFunction<List<T>,Map<K,V>>IFunction<? super T,Map.Entry<K,V>> mapBuilder
toMapFunction<List<T>,Map<K,V>>IFunction<? super T,K> keyFunction
IFunction<? super T,V> valueFunction
toSetFunction<List<T>,Set<T>>
zipAndGroupKeysFunction<List<T>,Map<K,List<T>>>K... keys
zipAndGroupKeysByFunction<List<T>,Map<K,List<T>>>IFunction<? super T, K> eval
zipAndGroupKeysFromFunction<List<T>,Map<K,List<T>>>Collection<K> keys
zipAndGroupKeysFromFunction<List<T>,Map<K,List<T>>>K[] keys
zipAndGroupValuesFunction<List<T>,Map<T,List<V>>>V... values
zipAndGroupValuesByFunction<List<T>,Map<T,List<V>>>IFunction<? super T, V> eval
zipAndGroupValuesFromFunction<List<T>,Map<T,List<V>>>Collection<V> values
zipAndGroupValuesFromFunction<List<T>,Map<T,List<V>>>V[] values
zipKeysFunction<List<T>,Map<K,T>>K... keys
zipKeysByFunction<List<T>,Map<K,T>>IFunction<? super T, K> eval
zipKeysFromFunction<List<T>,Map<K,T>>Collection<K> keys
zipKeysFromFunction<List<T>,Map<K,T>>K[] keys
zipValuesFunction<List<T>,Map<T,V>>V... values
zipValuesByFunction<List<T>,Map<T,V>>IFunction<? super T, V> eval
zipValuesFromFunction<List<T>,Map<T,V>>Collection<V> values
zipValuesFromFunction<List<T>,Map<T,V>>V[] values

FnListOfArrayOf

The functions in FnListOfArrayOf are applied on Lists of Arrays of any type. FnListOfArrayOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnList.ofArrayOf(Types.INTEGER), FnList.ofArrayOf(Types.LONG)). The example below shows how it can be used:

/* The code below flattens the target List of Array so, the result of the operation will be the list ["first", "second", "third"] */
Op.on(new String[][] {Op.onArrayFor("first", "second").get(), Op.onArrayFor("third").get()})
	.toList().exec(FnList.ofArrayOf(Types.STRING).flattenArrays()).get();
Function nameTypeParamsDescription
flattenArraysFunction<List<T[]>,List<T>>

FnListOfListOf

The functions in FnListOfListOf are applied on Lists of Lists of any type. FnListOfListOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnList.ofListOf(Types.INTEGER), FnList.ofListOf(Types.LONG)). The example below shows how it can be used:

/* Suppose we have a List<List<String>>, the piece of code below would return the flattened lists as a single list: ["first", "second", "third"] */
Op.onListFor(Op.onListFor("first", "second").get(), Op.onListFor("third").get())
              .exec(FnList.ofListOf(Types.STRING).flattenLists()).get();
Function nameTypeParamsDescription
flattenListsFunction<List<List<T>>,List<T>>

FnListOfSetOf

The functions in FnListOfSetOf are applied on Lists of Sets of any type. FnListOfSetOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnList.ofSetOf(Types.INTEGER), FnList.ofSetOf(Types.LONG)). The example below shows how it can be used:

/* Suppose we have a List<Set<String>>, the piece of code below would return the flattened sets as a single list: ["first", "second", "third"] */
Op.onListFor(Op.onSetFor("first", "second").get(), Op.onSetFor("third").get())
              .exec(FnList.ofSetOf(Types.STRING).flattenSets()).get()
Function nameTypeParamsDescription
flattenSetsFunction<List<Set<T>>,List<T>>