创建对应类型的 Predicates 的正确方式。

This commit is contained in:
2023-04-30 08:56:27 +08:00
parent ad01c58633
commit 9b268b668e
2 changed files with 10 additions and 9 deletions

View File

@@ -2,9 +2,13 @@ package xyz.zhouxy.plusone.commons.function;
import java.util.function.Predicate;
public class Predicates<T> {
public class Predicates {
public final Predicate<T> of(Predicate<? super T> predicate) {
public static <T> Predicate<T> of(Predicate<? super T> predicate) {
return predicate::test;
}
private Predicates() {
throw new IllegalStateException("Utility class");
}
}