public Builder ensureEnabled(Plugin plugin) { this.plugins.add(pair(plugin, true)); return this; }
public Builder ensureDisabled(Plugin plugin) { this.plugins.add(pair(plugin, false)); return this; }
public Builder ensureModuleEnabled(final Plugin plugin, String moduleKey) { if (!modules.containsKey(plugin)) { modules.put(plugin, Sets.<Pair<String, Boolean>>newHashSet()); } modules.get(plugin).add(pair(moduleKey, true)); return this; }
public Builder ensureModuleDisabled(final Plugin plugin, String moduleKey) { if (!modules.containsKey(plugin)) { modules.put(plugin, Sets.<Pair<String, Boolean>>newHashSet()); } modules.get(plugin).add(pair(moduleKey, false)); return this; }
private Pair<Order, String> extractOrderAndField(String orderQuery) { Matcher matcher = PREFIX_FIELD_PATTERN.matcher(nullToEmpty(orderQuery).trim()); matcher.find(); String prefix = matcher.group(1); Order order = Strings.isNullOrEmpty(prefix) ? Order.ASC : (prefix.equals("+") ? Order.ASC : Order.DESC); return pair(order, matcher.group(2)); } }
private static <K, V> List<Pair<K, V>> toList(Map<? extends K, ? extends V> map) { return map.entrySet().stream() .map(e -> pair(e.getKey(), e.getValue())) .collect(Collectors.toList()); } }
@Override public void addResult(final long count, final String msgKey) { results.add(Pair.pair(i18n.getText(msgKey), count)); }
public Builder ensureDisabled(String pluginKey) { this.plugins.add(pair(new SimplePlugin(pluginKey), false)); return this; }
public Builder level(Level level, String... loggers) { for (String logger : loggers) { levels.add(pair(logger, option(level))); } return this; }
public Builder ensureEnabled(String pluginKey) { this.plugins.add(pair(new SimplePlugin(pluginKey), true)); return this; } public Builder ensureEnabled(Plugin plugin)
public static <K, V> OrderedMapMatcher<K, V> orderedMap(K key1, V value1) { return orderedMap(ImmutableList.of(pair(key1, value1))); }
/** * Transforms list of Eithers into two lists, which contains left and right values. */ public static <L, R> Pair<List<L>, List<R>> splitEithers(final Iterable<Either<L, R>> eithers) { return Pair.<List<L>, List<R>>pair( ImmutableList.copyOf(Eithers.filterLeft(eithers)), ImmutableList.copyOf(Eithers.filterRight(eithers)) ); } }
@Override public Pair<Attachment, AttachmentKey> get(final Attachment attachment) { final Keys keys = issues.get(attachment.getIssueId()); return Pair.pair(attachment, AttachmentKeys.from(keys.projectKey, keys.issueKey, attachment)); } });
public static Optional<Pair<String, String>> getMethod(HttpServletRequest rq) { Document doc = readDocument(rq); if (null == doc) { return Optional.empty(); } Element root = doc.getRootElement(); if (null == root) { return Optional.empty(); } Element body = root.element("Body"); if (null == body) { return Optional.empty(); } Element methodElement = (Element) body.elements().get(0); if (null == methodElement) { return Optional.empty(); } String name = methodElement.getName(); String namespace = methodElement.getNamespaceURI(); return Optional.of(Pair.pair(namespace, name)); }
/** * This method gathers errors from all failed installations and combines them into one message. */ private String describeAllFailures(List<MarketplaceInstallationResult> installations) { return installations.stream() .filter(MarketplaceInstallationResult::failed) .map(failure -> failure .getException().map(ex -> ex.getI18nKey() != null ? pair(ex.getI18nKey(), ex.getI18nArgs()) : null) .orElse(pair(failure.getError().get().getI18nKey(), new String[]{failure.getAddonKey()}))) .map(pair -> i18nResolver.getText(pair.left(), pair.right())) .collect(Collectors.joining(" ")); } }
public Translations download(ConnectAddonBean addonBean) throws TranslationsDownloadException { List<DownloadResult<ResponsePromise>> downloadsInProgress = Stream.of(Language.values()) .map(lang -> pair(lang, lang.getPath(addonBean.getTranslations().getPaths()))) .filter(langAndPath -> langAndPath.right().isPresent()) .map(langAndPath -> scheduleDownload(langAndPath.left(), addonBean.getBaseUrl(), langAndPath.right().get())) .collect(toList()); final Map<Language, I18nKeysMapping> translations = downloadsInProgress.stream() .map(this::download) .collect(Collectors.toMap(DownloadResult::getLanguage, DownloadResult::getResult)); return Translations.from(translations); }
private List<Pair<String, Option<Level>>> configureLevels() { long start = System.currentTimeMillis(); List<Pair<String, Option<Level>>> transformed = newArrayList(); for (Pair<String, Option<Level>> level : levels) { Level newLevel = restClient.getAdminSession().getLoggingComponent().setLogLevel(level.left(), level.right().getOrNull()); transformed.add(pair(level.left(), option(newLevel))); } LOG.info("Changed log levels in {}ms: {}", System.currentTimeMillis() - start, levels); return transformed; }
@Override public Pair<HipChatUserId, String> apply(final AOHipChatUser input) { return Pair.pair(new HipChatUserId(input.getHipChatUserId(), new HipChatLinkId(input.getHipChatLink().getID())), input.getHipChatUserName()); } });