All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.kronicle.utils.StreamUtils Maven / Gradle / Ivy

package tech.kronicle.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;

public final class StreamUtils {

    public static  Predicate distinctByKey(Function keyExtractor) {
        Map seen = new HashMap<>();
        return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
    }

    private StreamUtils() {
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy