map multiple fields from java stream

Java
private static <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) 
{
  final Map<List<?>, Boolean> seen = new ConcurrentHashMap<>();
   
  return t -> 
  {
    final List<?> keys = Arrays.stream(keyExtractors)
                .map(ke -> ke.apply(t))
                .collect(Collectors.toList());
     
    return seen.putIfAbsent(keys, Boolean.TRUE) == null;
  };
}

Source

Also in Java: