FnArray 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 Arrays:
The functions in FnArrayOf are applied on Arrays. FnArrayOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnArray.ofBigDecimal(), FnArray.ofLong(), FnArray.of(final Type<T> type), ...).
FnArray.of(final Type<T> type) is the most generic method that gives you access to FnArrayOf though there are some shortcuts for common classes: FnArray.ofBigDecimal(), FnArray.ofInteger(), FnArray.ofDate(), FnArray.ofCharacter(), ...
The examples below show how these functions can be used:
/* This piece of code converts the Strings into Calendar and sorts them */ Op.on(new String[] {"2000/11/10", "2010/10/10", "2000/01/10"}) .forEach().exec(Types.CALENDAR, FnString.toCalendar("yyyy/MM/dd")).endFor() .exec(FnArray.ofCalendar().sort()).get(); /* This piece of code creates the map {first = [23], second = [2.3], third = [-23.456]} */ Op.on(new BigDecimal[] {BigDecimal.valueOf(23), BigDecimal.valueOf(2.3), BigDecimal.valueOf(-23.456)}) .exec(FnArray.ofBigDecimal().zipAndGroupKeys("first", "second", "third")).get(); /* This piece of code creates the map {ff0000 = red, 00ff00 = green, 0000ff = blue} */ Op.onArrayFor("ff0000", "red", "00ff00", "green", "0000ff", "blue") .exec(FnArray.ofString().couple()).get();
Function name | Type | Params | Description |
---|---|---|---|
add | Function<T[],T[]> | T... newElements | |
addAll | Function<T[],T[]> | Collection<T> collection | |
all | Function<T[],Boolean> | IFunction<? super T,Boolean> eval | |
any | Function<T[],Boolean> | IFunction<? super T,Boolean> eval | |
contains | Function<T[],Boolean> | T object | |
containsAll | Function<T[],Boolean> | T... objects | |
containsAny | Function<T[],Boolean> | T... objects | |
containsNone | Function<T[],Boolean> | T... objects | |
count | Function<T[],Integer> | ||
couple | Function<T[],Map<T,T>> | ||
coupleAndGroup | Function<T[],Map<T,T[]>> | ||
distinct | Function<T[],T[]> | ||
insert | Function<T[],T[]> | int position T... newElements | |
notContains | Function<T[],Boolean> | T object | |
removeAllEqual | Function<T[],T[]> | T... values | |
removeAllFalse | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
removeAllIndexes | Function<T[],T[]> | int... indexes | |
removeAllIndexesNot | Function<T[],T[]> | int... indexes | |
removeAllNotNullAndFalse | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
removeAllNotNullAndTrue | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
removeAllNull | Function<T[],T[]> | ||
removeAllNullOrFalse | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
removeAllNullOrTrue | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
removeAllTrue | Function<T[],T[]> | IFunction<? super T,Boolean> eval | |
reverse | Function<T[],T[]> | ||
sort | Function<T[],T[]> | ||
sort | Function<T[],T[]> | Comparator<? super T> comparator | |
sortBy | Function<T[],T[]> | IFunction<? super T, ?> by | |
toGroupMapOf | Function<T[],Map<K,V[]>> | Type<V> valueType IFunction<? super T,Map.Entry<K,V>> mapBuilder | |
toGroupMapOf | Function<T[],Map<K,V[]>> | Type<V> valueType IFunction<? super T,K> keyFunction IFunction<? super T,V> valueFunction | |
toList | Function<T[],List<T>> | ||
toMap | Function<T[],Map<K,V>> | IFunction<? super T,Map.Entry<K,V>> mapBuilder | |
toMap | Function<T[],Map<K,V>> | IFunction<? super T,K> keyFunction IFunction<? super T,V> valueFunction | |
toSet | Function<T[],Set<T>> | ||
zipAndGroupKeys | Function<T[],Map<K,T[]>> | K... keys | |
zipAndGroupKeysBy | Function<T[],Map<K,T[]>> | IFunction<? super T, K> eval | |
zipAndGroupKeysFrom | Function<T[],Map<K,T[]>> | Collection<K> keys | |
zipAndGroupKeysFrom | Function<T[],Map<K,T[]>> | K[] keys | |
zipAndGroupValues | Function<T[],Map<T,V[]>> | Type<V> valueType V... values | |
zipAndGroupValuesBy | Function<T[],Map<T,V[]>> | Type<V> valueType IFunction<? super T, V> eval | |
zipAndGroupValuesFrom | Function<T[],Map<T,V[]>> | Type<V> valueType Collection<V> values | |
zipAndGroupValuesFrom | Function<T[],Map<T,V[]>> | Type<V> valueType V[] values | |
zipKeys | Function<T[],Map<K,T>> | K... keys | |
zipKeysBy | Function<T[],Map<K,T>> | IFunction<? super T, K> eval | |
zipKeysFrom | Function<T[],Map<K,T>> | Collection<K> keys | |
zipKeysFrom | Function<T[],Map<K,T>> | K[] keys | |
zipValues | Function<T[],Map<T,V>> | V... values | |
zipValuesBy | Function<T[],Map<T,V>> | IFunction<? super T, V> eval | |
zipValuesFrom | Function<T[],Map<T,V>> | Collection<V> values | |
zipValuesFrom | Function<T[],Map<T,V>> | V[] values |
The functions in FnArrayOfArrayOf are applied on Arrays of Arrays of any type. FnArrayOfArrayOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnArray.ofArrayOf(Types.INTEGER), FnArray.ofArrayOf(Types.LONG)). The example below shows how it can be used:
/* The code below flattens the target Array of Array so, the result of the operation will be the array ["first", "second", "third"] */ Op.on(new String[][] {Op.onArrayFor("first", "second").get(), Op.onArrayFor("third").get()}) .castToArrayOf(Types.ARRAY_OF_STRING).exec( FnArray.ofArrayOf(Types.STRING).flattenArrays()).get();
Function name | Type | Params | Description |
---|---|---|---|
flattenArrays | Function<T[][],T[]> |
The functions in FnArrayOfListOf are applied on Arrays of Lists of any type. FnArrayOfListOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnArray.ofListOf(Types.INTEGER), FnArray.ofListOf(Types.LONG)). The example below shows how it can be used:
/* The code below flattens the target Array of List so, the result of the operation will be the array ["first", "second", "third"] */ Op.on(new List[] {Op.onListFor("first", "second").get(), Op.onListFor("third").get()}) .castToArrayOf(Types.LIST_OF_STRING).exec( FnArray.ofListOf(Types.STRING).flattenLists()).get();
Function name | Type | Params | Description |
---|---|---|---|
flattenLists | Function<List<T>[],T[]> |
The functions in FnArrayOfSetOf are applied on Arrays of Sets of any type. FnArrayOfSetOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnArray.ofSetOf(Types.INTEGER), FnArray.ofSetOf(Types.LONG)). The example below shows how it can be used:
/* The code below flattens the target Array of Set so, the result of the operation will be the array ["first", "second", "third"] */ Op.on(new Set[] {Op.onSetFor("first", "second").get(), Op.onSetFor("third").get()}) .castToArrayOf(Types.SET_OF_STRING).exec( FnArray.ofSetOf(Types.STRING).flattenSets()).get();
Function name | Type | Params | Description |
---|---|---|---|
flattenSets | Function<Set<T>[],T[]> |