map multiple fields from java stream

Solutions on MaxInterview for map multiple fields from java stream by the best coders in the world

showing results for - "map multiple fields from java stream"
Dayle
08 Jun 2018
1private static <T> Predicate<T> distinctByKeys(Function<? super T, ?>... keyExtractors) 
2{
3  final Map<List<?>, Boolean> seen = new ConcurrentHashMap<>();
4   
5  return t -> 
6  {
7    final List<?> keys = Arrays.stream(keyExtractors)
8                .map(ke -> ke.apply(t))
9                .collect(Collectors.toList());
10     
11    return seen.putIfAbsent(keys, Boolean.TRUE) == null;
12  };
13}
14