Example usage for java.util Collection toString

List of usage examples for java.util Collection toString

Introduction

In this page you can find the example usage for java.util Collection toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.architecturerules.services.AbstractArchitecturalRules.java

/**
 * just copy-n-pasted//from  w  w  w.  j a  v a2s . c  om
 * <code>org.architecturerules.services.CyclicRedundancyServiceImpl.buildListOfClasses(JavaPackage, JavaPackage)</code>
 * method from {@link CyclicRedundancyServiceImpl}
 * @param rule TODO
 */
@SuppressWarnings("unchecked")
private Collection<String> buildListOfClasses(Rule rule, final JavaPackage javaPackage,
        final JavaPackage dependency) {

    Collection<JavaClass> classesInPackage1 = javaPackage.getClasses();

    Collection<String> package1DependenciesOnPackage2 = JDependUtils.buildClasses(dependency.getName(),
            classesInPackage1);

    Collection<JavaClass> classesInPackage2 = dependency.getClasses();
    configuration.onPackageDependencyViolationDiscovered(rule, classesInPackage1.toString(),
            classesInPackage2.toString());

    return package1DependenciesOnPackage2;
}

From source file:org.apache.drill.exec.coord.zk.ZKClusterCoordinator.java

@Override
public Collection<DrillbitEndpoint> getOnlineEndPoints() {
    Collection<DrillbitEndpoint> runningEndPoints = new ArrayList<>();
    for (DrillbitEndpoint endpoint : endpoints) {
        if (isDrillbitInState(endpoint, State.ONLINE)) {
            runningEndPoints.add(endpoint);
        }/*from  w  ww  .  j  av a 2 s . c  o m*/
    }
    logger.debug("Online endpoints in ZK are" + runningEndPoints.toString());
    return runningEndPoints;
}

From source file:org.dataconservancy.dcs.ingest.file.StagedFileUploadManagerTest.java

@Test
public void calculatedDigestFileFixityTest() throws Exception {
    StagedFileUploadManager calcMgr = getUploadManager();
    calcMgr.setAlwaysCalculateFixityFor("MD5", "SHA");

    Collection<DcsFixity> fixity = parseContent(
            calcMgr.deposit(IOUtils.toInputStream(BASIC_CONTENT), "text/plain", null, null)).getFiles()
                    .iterator().next().getFixity();
    assertEquals(fixity.toString(), 2, fixity.size());
    for (DcsFixity f : fixity) {
        if (f.getAlgorithm().equals("MD5")) {
            assertEquals(toHex(MD5), f.getValue());
        }/*ww  w  .ja v  a  2s .c o m*/
        if (f.getAlgorithm().equals("SHA")) {
            assertEquals(toHex(SHA), f.getValue());
        }
    }

}

From source file:org.springframework.boot.actuate.autoconfigure.metrics.PublicMetricsAutoConfigurationTests.java

private void assertHasMetric(Collection<Metric<?>> metrics, Metric<?> metric) {
    for (Metric<?> m : metrics) {
        if (m.getValue().equals(metric.getValue()) && m.getName().equals(metric.getName())) {
            return;
        }//from ww w.j  av a 2 s  .  c o m
    }
    fail("Metric " + metric.toString() + " not found in " + metrics.toString());
}

From source file:ubic.gemma.web.controller.diff.DifferentialExpressionSearchController.java

/**
 * AJAX entry./*www  . jav a2 s. c o m*/
 * Value objects returned contain experiments that have 2 factors and have had the diff analysis run on it.
 */
public Collection<ExpressionExperimentExperimentalFactorValueObject> getFactors(final Collection<Long> eeIds) {

    Collection<ExpressionExperimentExperimentalFactorValueObject> result = new HashSet<>();

    final Collection<Long> securityFilteredIds = securityFilterExpressionExperimentIds(eeIds);

    if (securityFilteredIds.size() == 0) {
        return result;
    }

    log.debug("Getting factors for experiments with ids: "
            + StringUtils.abbreviate(securityFilteredIds.toString(), 100));

    Collection<Long> filteredEeIds = new HashSet<>();

    Map<Long, Collection<DifferentialExpressionAnalysis>> diffAnalyses = differentialExpressionAnalysisService
            .findByInvestigationIds(securityFilteredIds);

    if (diffAnalyses.isEmpty()) {
        log.debug("No differential expression analyses for given ids: " + StringUtils.join(filteredEeIds, ','));
        return result;
    }

    Collection<ExpressionExperimentValueObject> eevos = this.expressionExperimentService
            .loadValueObjects(diffAnalyses.keySet(), false);

    Map<Long, ExpressionExperimentValueObject> eevoMap = new HashMap<>();
    for (ExpressionExperimentValueObject eevo : eevos) {
        eevoMap.put(eevo.getId(), eevo);
    }

    for (Long id : diffAnalyses.keySet()) {

        Collection<DifferentialExpressionAnalysis> analyses = diffAnalyses.get(id);

        for (DifferentialExpressionAnalysis analysis : analyses) {
            differentialExpressionAnalysisService.thaw(analysis);

            Collection<ExperimentalFactor> factors = new HashSet<>();
            for (FactorAssociatedAnalysisResultSet fars : analysis.getResultSets()) {
                // FIXME includes factors making up interaction terms, but shouldn't
                // matter, because they will be included as main effects too. If not, this will be wrong!
                factors.addAll(fars.getExperimentalFactors());
            }

            filteredEeIds.add(id);
            ExpressionExperimentValueObject eevo = eevoMap.get(id);
            ExpressionExperimentExperimentalFactorValueObject eeefvo = new ExpressionExperimentExperimentalFactorValueObject();
            eeefvo.setExpressionExperiment(eevo);
            eeefvo.setNumFactors(factors.size());
            for (ExperimentalFactor ef : factors) {
                ExperimentalFactorValueObject efvo = geneDifferentialExpressionService
                        .configExperimentalFactorValueObject(ef);
                eeefvo.getExperimentalFactors().add(efvo);
            }

            result.add(eeefvo);
        }
    }
    log.info("Filtered experiments.  Returning factors for experiments with ids: "
            + StringUtils.abbreviate(filteredEeIds.toString(), 100));
    return result;
}

From source file:knowledgeMiner.mining.SentenceParserHeuristic.java

private String disambiguateTree(Parse parse, String[] predicateStrs, MappableConcept focusConcept,
        SortedMap<String, String> anchors, WMISocket wmi, OntologySocket cyc, MiningHeuristic heuristic,
        Collection<PartialAssertion> results) throws Exception {
    if (predicateStrs == null) {
        predicateStrs = new String[1];
        predicateStrs[0] = "";
    }//w ww . j  a v  a2  s  .c  o  m

    Parse[] children = parse.getChildren();
    String type = parse.getType();
    String text = parse.getCoveredText();

    // No children? Return value
    if (children.length == 0)
        return text;

    // Recurse to 'left'
    int childIndex = 0;
    String left = disambiguateTree(children[childIndex++], Arrays.copyOf(predicateStrs, predicateStrs.length),
            focusConcept, anchors, wmi, cyc, heuristic, results);

    // If VP or PP, add to predicate
    boolean canCreate = true;
    if (left != null) {
        if (type.equals("VP"))
            predicateStrs[0] = left.trim();
        else if (type.equals("PP")) {
            // If PP, split recursion into two predicates
            predicateStrs[0] = (predicateStrs[0] + " " + left).trim();
            if (!predicateStrs[0].equals(left)) {
                predicateStrs = Arrays.copyOf(predicateStrs, predicateStrs.length + 1);
                predicateStrs[predicateStrs.length - 1] = left;
            }
        }
    } else
        canCreate = false;

    for (; childIndex < children.length; childIndex++) {
        Parse childParse = children[childIndex];
        String result = disambiguateTree(childParse, Arrays.copyOf(predicateStrs, predicateStrs.length),
                focusConcept, anchors, wmi, cyc, heuristic, results);
        if (result == null) {
            canCreate = false;
        }
    }

    if (type.equals("VP") || type.equals("PP"))
        return null;

    // Can create and we have a target and predicate(s)
    if (canCreate && type.equals("NP") && !predicateStrs[0].isEmpty()) {
        for (String predStr : predicateStrs) {
            AssertionArgument predicate = null;
            if (isCopula(predStr)) {
                predicate = CycConstants.ISA_GENLS.getConcept();
            } else {
                // TODO Figure out a safe way to parse predicates. Probably
                // need to look at the parse code again.
                // predStr = reAnchorString(predStr, anchors);
                // predicate = new TextMappedConcept(predStr, true, true);
            }

            if (predicate == null)
                continue;

            // Return the possible noun strings
            Collection<Tree<String>> nounStrs = composeAdjNounsTree(parse, anchors);
            logger_.trace("createAssertions: " + predicate.toString() + " "
                    + nounStrs.toString().replaceAll("\\\\\n", " "));

            // Recurse through the tree and build the partial assertions
            HeuristicProvenance provenance = new HeuristicProvenance(heuristic, predStr + "+" + text);
            Collection<PartialAssertion> currAssertions = recurseStringTree(predicate, focusConcept, nounStrs,
                    provenance);

            // Add the assertions
            for (PartialAssertion pa : currAssertions)
                if (!results.contains(pa)) {
                    results.add(pa);
                    canCreate = false;
                }
        }
    }

    if (!canCreate)
        return null;

    return text;
}

From source file:org.kuali.rice.devtools.jpa.eclipselink.conv.parser.helper.AnnotationHelper.java

private String getTypeOrFieldNameForMsg(final BodyDeclaration n) {
    if (n instanceof TypeDeclaration) {
        return ((TypeDeclaration) n).getName();
    } else if (n instanceof FieldDeclaration) {
        final FieldDeclaration fd = (FieldDeclaration) n;
        //this wont work for nested classes but we should be in nexted classes at this point
        final CompilationUnit unit = getCompilationUnit(n);
        final TypeDeclaration parent = unit.getTypes().get(0);
        Collection<String> variableNames = new ArrayList<String>();
        if (fd.getVariables() != null) {
            for (VariableDeclarator vd : fd.getVariables()) {
                variableNames.add(vd.getId().getName());
            }// ww w  . jav a 2 s .  c o m
        }
        return variableNames.size() == 1 ? parent.getName() + "." + variableNames.iterator().next()
                : parent.getName() + "." + variableNames.toString();

    }
    return null;
}

From source file:org.kuali.kfs.module.ar.service.impl.CostCategoryServiceImpl.java

/**
 * @see org.kuali.kfs.module.ar.service.CostCategoryService#getBalancesForCostCategory(java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.kuali.kfs.module.ar.businessobject.CostCategory)
 *//* w  ww .j  av  a 2 s.co m*/
@Override
public List<Balance> getBalancesForCostCategory(Integer fiscalYear, String chartOfAccountsCode,
        String accountNumber, String balanceType, Collection<String> objectTypeCodes,
        CostCategory costCategory) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Retrieving balances for cost category: " + costCategory.getCategoryCode()
                + "; fiscal year = " + fiscalYear + "; chart: " + chartOfAccountsCode + "; account number: "
                + accountNumber + "; balance type: " + balanceType + "; object type codes: "
                + objectTypeCodes.toString());
    }
    return getCostCategoryDao().getBalancesForCostCategory(fiscalYear, chartOfAccountsCode, accountNumber,
            balanceType, objectTypeCodes, costCategory);
}

From source file:org.intermine.dwr.AjaxServices.java

/**
 * used on REPORT page//from   www . j  av  a2 s.c  o m
 *
 * For a gene, generate links to other intermines.  Include gene and orthologues.
 *
 * Returns NULL if no values found.  It's possible that the identifier in the local mine will
 * match more than one entry in the remote mine but this will be handled by the portal of the
 * remote mine.
 *
 * @param mineName name of mine to query
 * @param organisms gene.organism
 * @param identifiers identifiers for gene
 * @return the links to friendly intermines
 */
public static String getFriendlyMineLinks(String mineName, String organisms, String identifiers) {
    if (StringUtils.isEmpty(mineName) || StringUtils.isEmpty(organisms) || StringUtils.isEmpty(identifiers)) {
        return null;
    }
    final HttpSession session = WebContextFactory.get().getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    final ServletContext servletContext = WebContextFactory.get().getServletContext();
    final Properties webProperties = SessionMethods.getWebProperties(servletContext);
    final FriendlyMineManager fmm = FriendlyMineManager.getInstance(im, webProperties);
    InterMineLinkGenerator linkGen = null;
    Constructor<?> constructor;
    try {
        Class<?> clazz = TypeUtil.instantiate("org.intermine.bio.web.displayer.FriendlyMineLinkGenerator");
        constructor = clazz.getConstructor(new Class[] {});
        linkGen = (InterMineLinkGenerator) constructor.newInstance(new Object[] {});
    } catch (Exception e) {
        LOG.error("Failed to instantiate FriendlyMineLinkGenerator because: " + e);
        return null;
    }
    Collection<JSONObject> results = linkGen.getLinks(fmm, mineName, organisms, identifiers);
    if (results == null || results.isEmpty()) {
        return null;
    }
    return results.toString();
}

From source file:uk.ac.cam.cl.dtg.segue.dao.content.GitContentManager.java

@Override
public ResultsWrapper<ContentDTO> getContentMatchingIds(String version, Collection<String> ids, int startIndex,
        int limit) throws ContentManagerException {

    String k = "getContentMatchingIds~" + version + "~" + ids.toString() + "~" + startIndex + "~" + limit;
    if (!cache.asMap().containsKey(k)) {

        Map<String, AbstractFilterInstruction> finalFilter = Maps.newHashMap();
        finalFilter.putAll(new ImmutableMap.Builder<String, AbstractFilterInstruction>()
                .put(Constants.ID_FIELDNAME + "." + Constants.UNPROCESSED_SEARCH_FIELD_SUFFIX,
                        new TermsFilterInstruction(ids))
                .build());//w  ww . j  a v  a  2 s  .  c om

        if (getUnpublishedFilter() != null) {
            finalFilter.putAll(getUnpublishedFilter());
        }

        ResultsWrapper<String> searchHits = this.searchProvider.termSearch(version, CONTENT_TYPE, null, null,
                startIndex, limit, finalFilter);

        List<Content> searchResults = mapper.mapFromStringListToContentList(searchHits.getResults());
        cache.put(k, new ResultsWrapper<>(mapper.getDTOByDOList(searchResults), searchHits.getTotalResults()));
    }

    return (ResultsWrapper<ContentDTO>) cache.getIfPresent(k);
}