@Override public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException { Option<Pair<String, Object>> pair = invoke(targetObject, method); for (Pair<String, Object> tuple : pair) { Object value = tuple.second(); if (value instanceof Map) { //noinspection unchecked data.putAll((Map<String, Object>) value); } else { data.put(tuple.first(), value); } } } },
public boolean getSectionContainsAtleastOneLink(String parentSection, String section) { LinkedList<Pair<String,String>> parentAndSectionList = new LinkedList<>(); parentAndSectionList.add(Pair.nicePairOf(parentSection,section)); while (!parentAndSectionList.isEmpty()) { final Pair<String,String> currentPair = parentAndSectionList.pop(); final List<SimpleLinkSection> sectionList = getChildSectionsForSection(currentPair.second()); if (sectionList != null) { for (final SimpleLinkSection aSectionList : sectionList) { parentAndSectionList.addLast(Pair.of(currentPair.second(), aSectionList.getId())); } } final List<SimpleLink> links = getLinksForSection(currentPair.first(),currentPair.second()); if (links != null && !links.isEmpty()) { return true; } } return false; }
/** * By default we create a strict pair of non-null values. * * @param first first value * @param second second value * @param <U> type of first value * @param <V> type of second value * @return new pair * @see #strictPairOf(Object, Object) */ public static <U,V> Pair<U,V> of(U first, V second) { return strictPairOf(first, second); }
/** * Converts the usernames into User objects using the given function. * * @param watchers a Pair of watcher count and watcher usernames * @param function a Function used for conversion * @return a Pair of watcher count and User object */ protected <T extends ApplicationUser> Pair<Integer, List<T>> convertUsers(final Pair<Integer, List<String>> watchers, final Function<String, T> function) { return Pair.<Integer, List<T>>of( watchers.first(), copyOf(Iterables.transform(watchers.second(), function)) ); }
@Override public BulkWatchResult addWatcherToAll(final Collection<Issue> issues, final ApplicationUser remoteUser, final ApplicationUser watcher, final Context taskContext) throws WatchingDisabledException { Collection<Issue> successfulIssues = new ArrayList<Issue> (); Collection<Pair<Issue,String>> failedIssues = new ArrayList<Pair<Issue,String>> (); for (Issue issue : issues) { Pair<Boolean, String> canWatchIssue = canWatchIssue(issue, remoteUser, watcher); if (canWatchIssue.first().booleanValue()) { successfulIssues.add (issue); } else { failedIssues.add(Pair.nicePairOf(issue, canWatchIssue.second())); } } if (!successfulIssues.isEmpty()) { watcherManager.startWatching(watcher, successfulIssues, taskContext); } return new BulkWatchResult(failedIssues); }
public Option getChild() { return this.options.second(); }
public Option getParent() { return this.options.first(); }
public List<Review> apply(final FishEyeRepository repo) { try { return searchForReviews(query, repo); } catch (IOException e) { errors.add(Pair.of(repo, e)); return Collections.emptyList(); } } });
public CascadingOption (Option parent, Option child) { this.options = Pair.nicePairOf(parent, child); }
/** * A pair that does allows <code>null</code> values. * * @param first first value, may be <code>null</code> * @param second second value, may be <code>null</code> * @param <U> type of first value * @param <V> type of second value * @return new nice pair */ public static <U,V> Pair<U,V> nicePairOf(@Nullable U first, @Nullable V second) { return new Pair<U,V>(first, second); }
@Override public BulkWatchResult removeWatcherFromAll(final Collection<Issue> issues, final ApplicationUser remoteUser, final ApplicationUser watcher, final Context taskContext) throws WatchingDisabledException { Collection<Issue> successfulIssues = new ArrayList<Issue> (); Collection<Pair<Issue,String>> failedIssues = new ArrayList<Pair<Issue,String>> (); for (Issue issue : issues) { Pair<Boolean, String> canUnwatchIssue = canUnwatchIssue(issue, remoteUser, watcher); if (canUnwatchIssue.first().booleanValue()) { successfulIssues.add (issue); } else { failedIssues.add (Pair.nicePairOf(issue, canUnwatchIssue.second())); } } if (!successfulIssues.isEmpty()) { watcherManager.stopWatching(watcher, successfulIssues, taskContext); } return new BulkWatchResult(failedIssues); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UG_SYNC_SET_UNSYNC_GET", justification="This is a valid unsynchronized getter") public CurrentApplication getCurrentApplication() { return cache.get().second(); }
@Override public KeyPair getKeyPair() { return cache.get().first(); }
private static Pair<String, String> splitAndTrim(final String pluginModule) { String[] split = pluginModule.split(":"); String pluginKey = split.length < 1 ? "" : split[0].trim(); String moduleKey = split.length < 2 ? "" : split[1].trim(); return Pair.of(pluginKey, moduleKey); }
public MultipleKeyRegistrant<T> implementing(final Class<? super T> interfaceClass, final ComponentContainer.Scope desiredScope) { implementing.add(Pair.<Class<? super T>, ComponentContainer.Scope>nicePairOf(interfaceClass, desiredScope)); return this; }
/** * A pair that doesn't allow <code>null</code> values. * * @param first first value, may not be <code>null</code> * @param second second value, may not be <code>null</code> * @param <U> type of first value * @param <V> type of second value * @return new strict pair */ public static <U,V> Pair<U,V> strictPairOf(@Nonnull U first, @Nonnull V second) { return new Pair<U,V>(notNull("first", first), notNull("second", second)); }
@Override public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { Pair<ServletRequest, ServletResponse> debugWrapped = wrap(servletRequest, servletResponse); super.doFilter(debugWrapped.first(), debugWrapped.second(), filterChain); }
@Override public boolean isSnapshot() { return parseVersion(getVersion()).second().toUpperCase().startsWith("-SNAPSHOT"); }
public int[] getVersionNumbers() { return parseVersion(getVersion()).first(); }
public void recordTime(String sqlWithParams, String rawSql, final long timeTaken) { //looks like we're doing a really DB intense operation like indexing, data import etc. Probably //not worth it to record more that 500 statements. Cache will grow too big and kinda pointless for the // user to read through! int numOfStatements = inCallOrder.size(); if (numOfStatements >= MAX_STATEMENTS) { if (numOfStatements == MAX_STATEMENTS) { inCallOrder.add(Pair.of("More than 500 statements. Skipping remaining statements...", "")); } return; } totalTime += timeTaken; if (!timePerStatement.containsKey(rawSql)) { timePerStatement.put(rawSql, new ArrayList<Long>()); } timePerStatement.get(rawSql).add(timeTaken); inCallOrder.add(Pair.of(sqlWithParams, OfBizLogHelper.logTheCallStack())); }