標簽:java
函數(shù)式接口
-
Supplier<T>接口
Supplier<Integer> supplier=()->random.nextInt();
Supplier<T>接口,譯作供應商,提供一個獲取T類型對象的T get()函數(shù)
-
Consumer<T>接口
Consumer<Integer> consumer=integer->System.out.println("deal with "+integer);
Consumer<T>接口,譯作消費者,提供一個處理T類型對象的void accept(T)函數(shù)
-
Predicate<T>接口
Predicate<Integer> predicate=(integer)->integer>0;
Predicate<T>接口, 譯作驗證器,提供一個校驗T類型對象的boolean test(T)函數(shù)
-
To...Function接口
ToIntFunction<String> toIntFunction= (string)->Integer.valueOf(string); ToLongFunction<T> ToDoubleFunction<T>
To...Function接口,譯作。。類型轉(zhuǎn)換器,提供一個轉(zhuǎn)換T類型對象為指定。。的函數(shù)
-
..Function接口
IntFunction<String> intFunction=String::valueOf; LongFunction<R> DoubleFunction<R>
..Function接口,提供一個接受R類型對象轉(zhuǎn)換為原始類型的函數(shù)
-
Function<T,R>接口
Function<Integer,String> function= integer -> String.valueOf(integer);
Function<T,R>接口,普通函數(shù),提供一個接收T對象,返回R對象
-
BiFunction<T,R,U>
BiFunction<Integer,Long,String> biFunction= (intValue,longValue)->String.valueOf(intValue+longValue);
BiFunction<T,R,U>,提供一個接收T,R對象,返回U對象的函數(shù)
-
UnaryOperator接口
UnaryOperator<Integer> unaryOperator= integer -> integer++;
一元操作,繼承Function<T>接口
-
BinaryOperator接口
BinaryOperator<Integer> binaryOperator= (integer, integer2) -> integer+integer2;
二元操作,繼承BIFunction接口