/** * Returns a new {@link Promise} representing the status of a list of other * promises. * * @param promises The promises that the new promise should track * @return The new, aggregate promise */ public static <A> Promise<List<A>> when(Promise<? extends A>... promises) { return when(asList(promises)); }
private Promise<Result<List<CollapsedRoom>>> getRooms(final HipChatAPI hipChatAPI, final int startIndex, final ImmutableList.Builder<CollapsedRoom> currentRooms, final boolean includePrivate) { final ImmutableList.Builder<Promise<Result<AllRoomsResult>>> builder = ImmutableList.builder(); for (int i = 0; i < BATCH_SIZE; i++) { builder.add(hipChatAPI.rooms() .getAllRooms() .startIndex(startIndex + i * PAGE_SIZE) .maxResults(PAGE_SIZE) .includePrivate(includePrivate) .build()); } return Promises.when(builder.build()) .flatMap(toRoomList(hipChatAPI, startIndex, currentRooms, includePrivate)); }
private Promise<Map<String, Result<ExpandedRoom>>> expandRoomsForIds(final HipChatAPI hipChatAPI, final Iterable<String> roomIds, final ImmutableMap.Builder<String, Result<ExpandedRoom>> results) { final ImmutableList.Builder<Promise<RoomResult>> builder = ImmutableList .builder(); final boolean usingPersonalToken = hipChatAPI.getTokenType() instanceof HipChatAPI.TokenType.PersonalToken; //Only schedule at most BATCH_SIZE requests for (final String roomId : Iterables.take(BATCH_SIZE, roomIds)) { Promise<Result<ExpandedRoom>> roomPromise = hipChatAPI.rooms() .getRoom(roomId); if (!usingPersonalToken) { roomPromise = roomPromise.map(FILTER_PRIVATE_ROOM); } builder.add(roomPromise.map(toRoomResult(roomId))); } return Promises.when(builder.build()).flatMap(expandRoomBatch(hipChatAPI, roomIds, results)); }
Promises.when(ImmutableList.copyOf(Iterables.transform(attachments, move))).claim(); deleteThumbnailsDirectoryForIssue(oldIssue);
.when(ImmutableList.copyOf(Iterables.transform(attachments, copy))).claim(); final Map<Long, Either<AttachmentError, Attachment>> map = new HashMap<Long, Either<AttachmentError, Attachment>>(attachments.size()); for (final Pair<Long, Either<AttachmentError, Attachment>> result : results)
Promises.when(lastSynchronisedConnectDescriptorPromise, currentCapabilitiesConnectDescriptorPromise) .done(new Effect<List<ConnectDescriptor>>() { @Override