FnMap 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 Maps:
The functions in FnMapOf are applied on Maps. FnMapOf is a parameterizable class so, in order to use it, you must specify the type parameter (i.e. FnMap.ofIntegerString(), FnMap.ofStringString(), FnMap.of(final Type<K> keyType, final Type<V> valueType), ...).
FnMap.of(final Type<K> keyType, final Type<V> valueType) is the most generic method that gives you access to FnMapOf though there are some shortcuts for common classes: FnMap.ofIntegerString(), FnMap.ofObjectObject(), FnMap.ofStringInteger() and FnMap.ofStringString()
The examples below show how these functions can be used:
/* The piece of code below, creates a Map<Integer, String> and removes the entries with null value */ Op.onMapFor(Integer.valueOf(0), "all").put(Integer.valueOf(1), "first") .put(Integer.valueOf(2), null).put(Integer.valueOf(3), "third") .exec(FnMap.ofIntegerString().removeAllFalse( new IFunction<Map.Entry<Integer, String>, Boolean>() { public Boolean execute(Entry<Integer, String> input, ExecCtx ctx) throws Exception { return input.getValue() != null; } })).get()
Function name | Type | Params | Description |
---|---|---|---|
all | Function<Map<K,V>,Boolean> | IFunction<? super Map.Entry<K,V>,Boolean> eval | |
any | Function<Map<K,V>,Boolean> | IFunction<? super Map.Entry<K,V>,Boolean> eval | |
containsAllKeys | Function<Map<K,V>,Boolean> | K... keys | |
containsAnyKeys | Function<Map<K,V>,Boolean> | K... keys | |
containsKey | Function<Map<K,V>,Boolean> | K key | |
containsNoneKeys | Function<Map<K,V>,Boolean> | K... keys | |
count | Function<Map<?,?>,Integer> | ||
extractKeys | Function<Map<K,V>,Set<K>> | ||
extractValues | Function<Map<K,V>,List<V>> | ||
insert | Function<Map<K,V>,Map<K,V>> | int position K key V value | |
insertAll | Function<Map<K,V>,Map<K,V>> | int position Map<K,V> map | |
notContainsKey | Function<Map<K,V>,Boolean> | K key | |
put | Function<Map<K,V>,Map<K,V>> | K key V value | |
putAll | Function<Map<K,V>,Map<K,V>> | Map<K,V> map | |
removeAllFalse | Function<Map<K,V>,Map<K,V>> | IFunction<? super Entry<K,V>,Boolean> eval | |
removeAllKeys | Function<Map<K,V>,Map<K,V>> | K... keys | |
removeAllKeysNot | Function<Map<K,V>,Map<K,V>> | K... keys | |
removeAllTrue | Function<Map<K,V>,Map<K,V>> | IFunction<? super Entry<K,V>,Boolean> eval | |
reverse | Function<Map<K,V>,Map<K,V>> | ||
sortBy | Function<Map<K,V>,Map<K,V>> | IFunction<? super Map.Entry<K,V>, ?> by | |
sortByKey | Function<Map<K,V>,Map<K,V>> | ||
sortEntries | Function<Map<K,V>,Map<K,V>> | Comparator<? super Entry<K,V>> comparator |