shz.core.serializable.SerializableComparator Maven / Gradle / Ivy
package shz.core.serializable;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects;
@FunctionalInterface
public interface SerializableComparator extends Comparator, Serializable {
static SerializableComparator comparingInt(SerializableToIntFunction super T> keyExtractor) {
Objects.requireNonNull(keyExtractor);
return (SerializableComparator & Serializable) (c1, c2) -> Integer.compare(keyExtractor.applyAsInt(c1), keyExtractor.applyAsInt(c2));
}
static SerializableComparator comparingLong(SerializableToLongFunction super T> keyExtractor) {
Objects.requireNonNull(keyExtractor);
return (SerializableComparator & Serializable) (c1, c2) -> Long.compare(keyExtractor.applyAsLong(c1), keyExtractor.applyAsLong(c2));
}
}