public static <K, V, E> Map<K, V> makeMap( Collection<E> collection, Function<E,K> keyProducer, Function<E,V> valueProducer) { if ( isEmpty( collection ) ) { return Collections.emptyMap(); } final Map<K, V> map = new HashMap<>(); for ( E element : collection ) { map.put( keyProducer.apply( element ), valueProducer.apply( element ) ); } return map; }
public static <K, V, E> Map<K, V> makeMap( Collection<E> collection, Function<E,K> keyProducer, Function<E,V> valueProducer) { if ( isEmpty( collection ) ) { return Collections.emptyMap(); } final Map<K, V> map = new HashMap<>(); for ( E element : collection ) { map.put( keyProducer.apply( element ), valueProducer.apply( element ) ); } return map; }