code: public static <K, V> Map<K, V> map( Collection<V> values, Function<V, K> key )
      {
          if ( Objects.requireNonNull( values, "values" ).size() == 0 )
          {
              return emptyMap();
          }
          Objects.requireNonNull( key, "key function" );
          Map<K, V> result = new HashMap<>( (int) (values.size() / 0.75) );
          for ( V value : values )
          {
              K k = key.apply( value );
              if ( k != null )
              {
                  if ( result.put( k, value ) != null )
                  {
                      throw new IllegalArgumentException( "Duplicate key: " + k );
                  }
              }
          }
          return result;
      }
docs: Create a {@link Map} by applying a function that extracts the key from a collection of values.
  
  @param values the values of the map (from which the keys are extracted).
  @param key    the key extraction function.
  @param <K>    the type of the keys.
  @param <V>    the type of the values.
  @return a {@link Map} from the keys of the values to the values.