public static <T> Predicate<T> distinctByKey(final Function<? super T, ?> keyExtractor) {
        val seen = ConcurrentHashMap.newKeySet();
        return t -> seen.add(keyExtractor.apply(t));
    }
Distinct by key predicate.

@param <T>          the type parameter
@param keyExtractor the key extractor
@return the predicate
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/CollectionUtils.java