Check out example codes for "map multiple fields from java stream". It will help you in understanding the concepts better.

Code Example 1

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;
  };
}

Learn ReactJs, React Native from akashmittal.com