package eu.mhsl.minecraft.pixelblocks.utils;

import java.util.Comparator;
import java.util.List;
import java.util.function.Function;

public class MinMaxUtil {
    public static <I, O extends Comparable<O>> O getMinProperty(List<I> list, Function<I, O> supplier) {
        return supplier.apply(list.stream().min(Comparator.comparing(supplier)).orElseThrow());
    }

    public static <I, O extends Comparable<O>> O getMaxProperty(List<I> list, Function<I, O> supplier) {
        return supplier.apply(list.stream().max(Comparator.comparing(supplier)).orElseThrow());
    }
}
