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