public List<Review> apply(final FishEyeRepository repo) { try { return searchForReviews(query, repo); } catch (IOException e) { errors.add(Pair.of(repo, e)); return Collections.emptyList(); } } });
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 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())); }
private Pair<InputStream, Effect<Object>> getInputStreamForFile(final File file, final Effect<Object> effect) throws IOException { final InputStream fileInputStream = ioUtilsWrapper.openInputStream(file); return Pair.<InputStream, Effect<Object>>of(fileInputStream, new Effect<Object>() { @Override public void apply(final Object ignore) { try { effect.apply(ignore); } finally { IOUtils.closeQuietly(fileInputStream); } } }); } }
private Pair<ServletRequest, ServletResponse> wrap(final ServletRequest servletRequest, final ServletResponse servletResponse) { // only in dev mode do we have these classes. There are only there as a development aid if (JiraSystemProperties.isDevMode()) { return Pair.<ServletRequest, ServletResponse>of( new BreakpointReadyHttpServletRequest((HttpServletRequest) servletRequest), wrapServletResponse(servletResponse) ); } return Pair.of(servletRequest, servletResponse); }
/** package-scope for for testing */ static Pair<int[], String> parseVersion(String version) { List<Integer> ints = new LinkedList<Integer>(); Matcher m = Pattern.compile("([0-9]+)(\\.?)(.*)").matcher(""); String rest = version; while (m.reset(rest).matches()) { String i = m.group(1); ints.add(Integer.parseInt(i)); String dot = m.group(2); rest = m.group(3); if (!".".equals(dot)) { break; // no more numbers to be had } } while (ints.size() < 3) { // make sure there is always at least 3 ints.add(0); } return Pair.of(Ints.toArray(ints), rest); } }
/** * 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)) ); }
private Pair<Set<String>, Map<String, Set<Long>>> breakDownIssueKeys(@Nonnull final Set<String> issueKeys) { Set<String> invalidKeys = new HashSet<>(); Map<String, Set<Long>> projectKeyIssueNumbers = new HashMap<>(); for (String issueKey : issueKeys) { IssueKey issueKeyObject; try { issueKeyObject = IssueKey.from(issueKey); } catch (IllegalArgumentException ex) { invalidKeys.add(issueKey); continue; } Set<Long> issueNumbers = projectKeyIssueNumbers.get(issueKeyObject.getProjectKey()); if (issueNumbers == null) { issueNumbers = new HashSet<>(); projectKeyIssueNumbers.put(issueKeyObject.getProjectKey(), issueNumbers); } issueNumbers.add(issueKeyObject.getIssueNumber()); } return Pair.of(invalidKeys, projectKeyIssueNumbers); }
private Set<Pair<Long, String>> getProjectIssueTypes(final ApplicationUser searcher, final List<QueryLiteral> literals) { Set<Pair<Long, String>> projectIssueTypes = new HashSet<Pair<Long, String>>(); for (QueryLiteral literal : literals) { // if we have an empty literal, the Global context will not impact on any existing contexts, so do nothing if (!literal.isEmpty()) { for (Issue issue : getIssues(searcher, literal)) { projectIssueTypes .add(Pair.of(issue.getProjectId(), issue.getIssueTypeId())); } } } return projectIssueTypes; }
private Pair<Set<FishEyeRepository>, Map<FishEyeInstance, Set<FishEyeRepository>>> splitOutLegacyRepositories(String projectKey, Collection<FishEyeRepository> allRepositories) { Set<FishEyeRepository> legacyReposToSearch = new HashSet<FishEyeRepository>(); Map<FishEyeInstance, Set<FishEyeRepository>> instancesToSearch = new HashMap<FishEyeInstance, Set<FishEyeRepository>>(); if (!repositoryStore.isMapped(projectKey)) { for (FishEyeInstance instance : instanceStore.getAllFishEyeInstances()) { if (instance.isCrossRepoCapable(apiManager)) { instancesToSearch.put(instance, new HashSet<FishEyeRepository>()); } } } for (FishEyeRepository repository : allRepositories) { boolean crossRepoCapable = repository.getInstance().isCrossRepoCapable(apiManager); if (!crossRepoCapable) { legacyReposToSearch.add(repository); } else { Set<FishEyeRepository> repositories = instancesToSearch.get(repository.getInstance()); if (repositories == null) { repositories = new HashSet<FishEyeRepository>(); instancesToSearch.put(repository.getInstance(), repositories); } repositories.add(repository); } } return Pair.of(legacyReposToSearch, instancesToSearch); }
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; }
private Set<Pair<Long, String>> getProjectIssueTypePairs(@Nonnull final Collection<String> fields, @Nonnull final EntityCondition condition) { OfBizListIterator iterator = null; try { iterator = ofBizDelegator.findListIteratorByCondition(Entity.Name.ISSUE, condition, null, fields, null, null); Set<Pair<Long, String>> projectIssueTypes = new HashSet<>(); GenericValue genericValue = iterator.next(); while (genericValue != null) { Long projectId = genericValue.getLong(IssueFieldConstants.PROJECT); String issueTypeId = genericValue.getString("type"); projectIssueTypes.add(Pair.of(projectId, issueTypeId)); genericValue = iterator.next(); } return projectIssueTypes; } finally { if (iterator != null) { iterator.close(); } } }
return Pair.of(watcherCount, watcherNames);
public Option<Pair<String, ErrorCollection.Reason>> validateName(final String name, final Option<IssueType> issueTypeToUpdate) { if (isBlank(name)) { return Option.some(Pair.of(authenticationContext.getI18nHelper().getText("admin.errors.must.specify.name"), VALIDATION_FAILED)); } else if (length(name) > 60) { return Option.some(Pair.of(authenticationContext.getI18nHelper().getText("admin.errors.issuetypes.name.must.not.exceed.max.length"), VALIDATION_FAILED)); } else { for (final IssueType issueType : getAllIssueTypeObjects()) { if ((issueTypeToUpdate.isDefined() && !issueTypeToUpdate.get().equals(issueType)) || issueTypeToUpdate.isEmpty()) { if (name.trim().equalsIgnoreCase(issueType.getName())) { return Option.some(Pair.of(authenticationContext.getI18nHelper().getText("admin.errors.issue.type.with.this.name.already.exists"), CONFLICT)); } } } } return Option.none(); }
EVENT_SHOWS_IN_CLOUD_LOG, changedValue); return Pair.of(migrationState.log(event), true); "Service Desk not migrated", builder.toString(), AssociatedItem.Type.APPLICATION_ROLE, null, EVENT_SHOWS_IN_CLOUD_LOG, emptyList(), AuditEntrySeverity.WARNING)); return Pair.of(result, false); + " Service Desk.", AssociatedItem.Type.APPLICATION_ROLE)); return Pair.of(result, true);
return Pair.of(keyPair, application);