Example usage for org.apache.commons.collections MapUtils transformedMap

List of usage examples for org.apache.commons.collections MapUtils transformedMap

Introduction

In this page you can find the example usage for org.apache.commons.collections MapUtils transformedMap.

Prototype

public static Map transformedMap(Map map, Transformer keyTransformer, Transformer valueTransformer) 

Source Link

Document

Returns a transformed map backed by the given map.

Usage

From source file:org.openengsb.core.services.internal.deployer.connector.ConnectorFile.java

private ImmutableMap<String, String> getFilteredEntries(Map<String, String> propertyMap, final String prefix) {
    @SuppressWarnings("unchecked")
    Map<String, String> transformedMap = MapUtils.transformedMap(new HashMap<String, String>(),
            new Transformer() {
                @Override/*w  w w .jav a 2 s .  c  om*/
                public Object transform(Object input) {
                    return ((String) input).replaceFirst(prefix + ".", "");
                }
            }, null);
    Map<String, String> filterEntries = Maps.filterEntries(propertyMap,
            new Predicate<Map.Entry<String, String>>() {
                @Override
                public boolean apply(Entry<String, String> input) {
                    return input.getKey().startsWith(prefix + ".");
                }
            });
    transformedMap.putAll(filterEntries);
    return ImmutableMap.copyOf(transformedMap);
}