Stream api2
Collect to Map
Map < String , String > result = effectList. stream ( ) . collect (
Collectors . toMap ( BusiDisposalProveEffectInfo :: getDeclareId ,
BusiDisposalProveEffectInfo :: getRegAttachmentId ) ) ;
Collect to List or Set
List < String > idList = resultList. stream ( ) . map ( BusiDisposalProveListVO :: getId ) . collect ( Collectors . toList ( ) ) ;
Filter
Set < String > idSet = resultList. stream ( )
. filter ( e -> StringUtils . equals ( e. getStatus ( ) , DeclareStatusEnum . SUCCESS . getCode ( ) ) )
. map ( BusiDisposalProveListVO :: getId )
. collect ( Collectors . toSet ( ) ) ;
Consumer
public void f1 ( int a, int b, Consumer < Integer > callback) {
callback. accept ( a+ b) ;
}
f1 ( 1 , 2 , result -> {
System . out. println ( result) ;
} )