Functions: FnMap

1. Overview

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:

FnMapOf

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 nameTypeParamsDescription
allFunction<Map<K,V>,Boolean>IFunction<? super Map.Entry<K,V>,Boolean> eval
anyFunction<Map<K,V>,Boolean>IFunction<? super Map.Entry<K,V>,Boolean> eval
containsAllKeysFunction<Map<K,V>,Boolean>K... keys
containsAnyKeysFunction<Map<K,V>,Boolean>K... keys
containsKeyFunction<Map<K,V>,Boolean>K key
containsNoneKeysFunction<Map<K,V>,Boolean>K... keys
countFunction<Map<?,?>,Integer>
extractKeysFunction<Map<K,V>,Set<K>>
extractValuesFunction<Map<K,V>,List<V>>
insertFunction<Map<K,V>,Map<K,V>>int position
K key
V value
insertAllFunction<Map<K,V>,Map<K,V>>int position
Map<K,V> map
notContainsKeyFunction<Map<K,V>,Boolean>K key
putFunction<Map<K,V>,Map<K,V>>K key
V value
putAllFunction<Map<K,V>,Map<K,V>>Map<K,V> map
removeAllFalseFunction<Map<K,V>,Map<K,V>>IFunction<? super Entry<K,V>,Boolean> eval
removeAllKeysFunction<Map<K,V>,Map<K,V>>K... keys
removeAllKeysNotFunction<Map<K,V>,Map<K,V>>K... keys
removeAllTrueFunction<Map<K,V>,Map<K,V>>IFunction<? super Entry<K,V>,Boolean> eval
reverseFunction<Map<K,V>,Map<K,V>>
sortByFunction<Map<K,V>,Map<K,V>>IFunction<? super Map.Entry<K,V>, ?> by
sortByKeyFunction<Map<K,V>,Map<K,V>>
sortEntriesFunction<Map<K,V>,Map<K,V>>Comparator<? super Entry<K,V>> comparator