@Override public Iterable<HipChatMessage> apply(final String renderedMessage) { return Iterables.flatMap(notificationInfos, new Function<NotificationInfo, Iterable<HipChatMessage>>() { @Override public Iterable<HipChatMessage> apply(@Nullable NotificationInfo notificationInfo) { try { return Collections.singleton( new HipChatMessage.Builder().setRoomName(notificationInfo.getRoomNameOrId()) .setMessage(renderedMessage) .setBgColor(HipChatNotificationOptions.GRAY.getBackgroundColor()) .setNotifyingClients(notificationInfo.isNotifyingClients()) .build()); } catch (Exception e) { throw new RuntimeException(e); } } }); } }).getOrElse(Collections.<HipChatMessage>emptyList());
private static List<String> convertToCommitMessages(RestDevResponse<RestChangesetRepository> response) { List<RestChangesetRepository> results = response.getRepositories(); Iterable<String> transformedResults = Iterables.flatMap(results, new Function<RestChangesetRepository, Iterable<String>>() { @Override public Iterable<String> apply(@Nullable final RestChangesetRepository input) { return Collections2.transform(input.getCommits(), new Function<RestChangeset, String>() { @Override public String apply(@Nullable final RestChangeset input) { return input.getMessage(); } }); } }); return Lists.newArrayList(transformedResults); }
@Override protected Iterable<HipChatMessage> doRender(ConfigurationEvent configurationEvent, Iterable<NotificationInfo> notificationInfos) { final String renderedMessage = renderNotification(configurationEvent); return Iterables.flatMap(notificationInfos, new Function<NotificationInfo, Iterable<HipChatMessage>>() { @Override public Iterable<HipChatMessage> apply(@Nullable NotificationInfo notificationInfo) { return Collections.singleton( new HipChatMessage.Builder().setRoomName(notificationInfo.getRoomNameOrId()) .setMessage(renderedMessage) .setBgColor(HipChatNotificationOptions.GREEN.getBackgroundColor()) .setNotifyingClients(notificationInfo.isNotifyingClients()) .build()); } }); }
@Override public Iterable<Pair<JiraIssueEvent,NotificationInfo>> apply(@Nullable ProjectConfigurationGroupSelector selector) { try { return Iterables.flatMap(taskBuilder.newFilterTask(event, selector).call(), new Function<NotificationInfo, Iterable<Pair<JiraIssueEvent, NotificationInfo>>>() { @Override public Iterable<Pair<JiraIssueEvent, NotificationInfo>> apply(@Nullable NotificationInfo input) { return Collections.singleton(new Pair<JiraIssueEvent,NotificationInfo>(event, input)); } }); } catch (Exception e) { throw new RuntimeException("Error processing task", e); } } });
/** * @return a list of links in the current editor. There is no guaranteed ordering, and may not appear in page order. * @since 5.8.0 */ public List<EditorEmbeddedLink> getEmbeddedLinks() { return execute.onTinyMceIFrame(() -> { final Iterable<PageElement> allEmbeddedResourceLinks = flatMap(LINKED_SELECTORS, toPageElements()); //this list must not be lazy, since we need to execute it in the context of the editor iframe. return newArrayList(transform(allEmbeddedResourceLinks, toEditorEmbeddedLink())); }); }
@Override protected Iterable<HipChatMessage> doRender(final JiraPostFunctionEvent event, final Iterable<NotificationInfo> notificationInfos) { try { final String renderedMessage = event.isHavingErrors() ? renderErrorNotification(event) : renderNotification(event); return Iterables.flatMap(notificationInfos, new Function<NotificationInfo, Iterable<HipChatMessage>>() { @Override public Iterable<HipChatMessage> apply(@Nullable NotificationInfo notificationInfo) { Option<MessageBgColor> bgColor = (event.isHavingErrors() ? HipChatNotificationOptions.RED : HipChatNotificationOptions.GRAY).getBackgroundColor(); return Collections.singleton( new HipChatMessage.Builder().setRoomName(notificationInfo.getRoomNameOrId()) .setMessage(renderedMessage) .setNotifyingClients(notificationInfo.isNotifyingClients()) .setBgColor(bgColor) .build()); } }); } catch (MessageRendererException e) { return Collections.emptyList(); } }
Iterable<ProjectConfigurationGroupSelector> selectors = Iterables.flatMap(configurations, new Function<ProjectConfiguration, Iterable<ProjectConfigurationGroupSelector>>() { @Override return Iterables.flatMap(selectors, new Function<ProjectConfigurationGroupSelector, Iterable<Pair<JiraIssueEvent,NotificationInfo>>>() { @Override public Iterable<Pair<JiraIssueEvent,NotificationInfo>> apply(@Nullable ProjectConfigurationGroupSelector selector) {