Java tutorial
//package com.java2s; //License from project: LGPL import java.util.HashMap; import java.util.Map; import java.util.function.Function; public class Main { public static final <D, E, F> Map<D, F> reMap(Map<? extends E, F> sourceMap, Function<E, D> mapping) { Map<D, F> resultMap = new HashMap<D, F>(); for (E key : sourceMap.keySet()) { resultMap.put(mapping.apply(key), sourceMap.get(key)); } return resultMap; } }