-
Predicate<T>
谓词
-
test(T):boolean
计算给定的谓词的值
Predicate<Long> predicate = (l) -> l > 0L; predicate.test(3L); // true
-
and(Predicate<? super T>):Predicate<T>
返回一个与原谓词与关系组合后的谓词
Predicate<Long> predicate = (l) -> l > 0L; predicate.and(l -> l < 10L).test(3L); // true predicate.and(l -> l > 10L).test(3L); // false
-
or(Predicate<? super T>):Predicate<T>
返回一个与原谓词或关系组合后的谓词
Predicate<Long> predicate = (l) -> l == 0L; predicate.or(l -> l > 10L).test(15L); // true
-
negate():Predicate<T>
返回一个与原谓词非关系的谓词
Predicate<Long> predicate = (l) -> l > 0L; predicate.negate().test(5L); // false
-
isEqual(Object):Predicate<T>
返回一个判断两个参数是否相等的谓词
Predicate<String> predicate = Predicate.isEqual("string"); predicate.test("what"); // false
-
-
Function<T, R>
函数
-
apply(T):R
给定参数应用于指定的函数. 返回一个结果
Function<Long, String> function = String::valueOf; function.apply(40L); // "40"
-
compose(Function<? super V, ? extends T>):Function<V, R>
在原函数执行前执行给定参数的函数, 返回组合后的函数
Function<Long, String> function = String::valueOf; String apply = function.compose(l -> (long) l.hashCode() + 30L).apply(40L); // 40
-
andThen(Function<? super V, ? extends T>):Function<V, R>
在原函数执行后执行给定参数的函数, 返回组合后的函数
Function<Long, String> function = String::valueOf; Long apply1 = function.andThen(l -> (long) l.hashCode() - 30L).apply(100L); // 48595
-
identity():Function<T, T>
返回一个始终返回输入参数的函数
Function<Object, Object> identity = Function.identity(); Object string = identity.apply("String"); // "String"
-
-
Supplier<T>
提供者
-
get():T
根据给定的类属性产生一个对象
Supplier<Student> supplier = Student::new; Student student = supplier.get();
-
-
Consumer<T>
消费者
-
accept(T):void
对给定的参数进行一系列预定义的流程处理
Consumer<Student> consumer = student -> student.setName("peter"); consumer.accept(new Student());
-
andThen(Consumer<? super T>):Consumer<T>
在对给定的参数处理后再进行后续的流程处理. 返回组合流程后的消费者
Consumer<Student> consumer = student -> student.setName("peter"); consumer.andThen(System.out::println).accept(new Student());
-
网友评论