@ SuppressWarnings ( "unchecked" ) public static < T > PromisesArray < T > of ( Collection < T > collection ) { final ArrayList < Promise < T > > res = new ArrayList <> ( ) ; for ( T t : collection ) { res . add ( Promise . success ( t ) ) ; } final Promise [ ] promises = res . toArray ( new Promise [ res . size ( ) ] ) ; return new PromisesArray <> ( ( PromiseFunc < Promise < T > [ ] > ) executor -> { executor . result ( promises ) ; } ) ; }
Create PromisesArray from collection