code: public static <T> Collector<T, ?, List<T>> distinctBy(Function<? super T, ?> mapper) {
          return Collector.<T, Map<Object, T>, List<T>> of(LinkedHashMap::new, (map, t) -> map.putIfAbsent(mapper.apply(
              t), t), (m1, m2) -> {
                  for (Entry<Object, T> e : m2.entrySet()) {
                      m1.putIfAbsent(e.getKey(), e.getValue());
                  }
                  return m1;
              }, map -> new ArrayList<>(map.values()));
      }
docs: Returns a {@code Collector} which collects into the {@link List} the
  input elements for which given mapper function returns distinct results.
  
  <p>
  For ordered source the order of collected elements is preserved. If the
  same result is returned by mapper function for several elements, only the
  first element is included into the resulting list.
  
  <p>
  There are no guarantees on the type, mutability, serializability, or
  thread-safety of the {@code List} returned.
  
  <p>
  The operation performed by the returned collector is equivalent to
  {@code stream.distinct(mapper).toList()}, but may work faster.
  
  @param <T> the type of the input elements
  @param mapper a function which classifies input elements.
  @return a collector which collects distinct elements to the {@code List}.
  @since 0.3.8