/** * Factory method to create a transforming map that will transform * existing contents of the specified map. * <p> * If there are any elements already in the map being decorated, they * will be transformed by this method. * Constrast this with {@link #decorate}. * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation * @param valueTransformer the transformer to use for value conversion, null means no transformation * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ public static java.util.Map <Object, Object> decorateTransform(java.util.Map <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer) { TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer); if (map.size() > 0) { java.util.Map <Object, Object> transformed = decorated.transformMap(map); decorated.clear(); decorated.getMap().putAll(transformed); // avoids double transformation } return(decorated); }
/** * Factory method to create a transforming map that will transform * existing contents of the specified map. * <p> * If there are any elements already in the map being decorated, they * will be transformed by this method. * Constrast this with {@link #decorate}. * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation * @param valueTransformer the transformer to use for value conversion, null means no transformation * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ public static java.util.Map<Object, Object> decorateTransform(java.util.Map<Object, Object> map, Transformer keyTransformer, Transformer valueTransformer) { TransformedMap decorated = new TransformedMap(map, keyTransformer, valueTransformer); if (map.size() > 0) { java.util.Map<Object, Object> transformed = decorated.transformMap(map); decorated.clear(); decorated.getMap().putAll(transformed); // avoids double transformation } return decorated; }