Example usage for java.util Set toString

List of usage examples for java.util Set toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.apache.tinkerpop.gremlin.python.jsr223.PythonTranslator.java

protected String convertToString(final Object object) {
    if (object instanceof Bytecode.Binding)
        return ((Bytecode.Binding) object).variable();
    else if (object instanceof Bytecode)
        return this.internalTranslate("__", (Bytecode) object);
    else if (object instanceof Traversal)
        return convertToString(((Traversal) object).asAdmin().getBytecode());
    else if (object instanceof String)
        return ((String) object).contains("\"") ? "\"\"\"" + object + "\"\"\"" : "\"" + object + "\"";
    else if (object instanceof Set) {
        final Set<String> set = new LinkedHashSet<>(((Set) object).size());
        for (final Object item : (Set) object) {
            set.add(convertToString(item));
        }/*w w  w  .j a v  a2  s  .com*/
        return "set(" + set.toString() + ")";
    } else if (object instanceof List) {
        final List<String> list = new ArrayList<>(((List) object).size());
        for (final Object item : (List) object) {
            list.add(convertToString(item));
        }
        return list.toString();
    } else if (object instanceof Map) {
        final StringBuilder map = new StringBuilder("{");
        for (final Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
            map.append(convertToString(entry.getKey())).append(":").append(convertToString(entry.getValue()))
                    .append(",");
        }
        return map.length() > 1 ? map.substring(0, map.length() - 1) + "}" : map.append("}").toString();
    } else if (object instanceof Long)
        return object + "L";
    else if (object instanceof TraversalStrategyProxy) {
        final TraversalStrategyProxy proxy = (TraversalStrategyProxy) object;
        if (proxy.getConfiguration().isEmpty())
            return "TraversalStrategy(\"" + proxy.getStrategyClass().getSimpleName() + "\")";
        else
            return "TraversalStrategy(\"" + proxy.getStrategyClass().getSimpleName() + "\","
                    + convertToString(ConfigurationConverter.getMap(proxy.getConfiguration())) + ")";
    } else if (object instanceof TraversalStrategy) {
        return convertToString(new TraversalStrategyProxy((TraversalStrategy) object));
    } else if (object instanceof Boolean)
        return object.equals(Boolean.TRUE) ? "True" : "False";
    else if (object instanceof Class)
        return ((Class) object).getCanonicalName();
    else if (object instanceof VertexProperty.Cardinality)
        return "Cardinality." + SymbolHelper.toPython(object.toString());
    else if (object instanceof SackFunctions.Barrier)
        return "Barrier." + SymbolHelper.toPython(object.toString());
    else if (object instanceof TraversalOptionParent.Pick)
        return "Pick." + SymbolHelper.toPython(object.toString());
    else if (object instanceof Enum)
        return convertStatic(((Enum) object).getDeclaringClass().getSimpleName() + ".")
                + SymbolHelper.toPython(object.toString());
    else if (object instanceof P)
        return convertPToString((P) object, new StringBuilder()).toString();
    else if (object instanceof Element) {
        final String id = convertToString(((Element) object).id());
        if (object instanceof Vertex)
            return "Vertex(" + id + "," + convertToString(((Vertex) object).label()) + ")";
        else if (object instanceof Edge) {
            final Edge edge = (Edge) object;
            return "Edge(" + id + "," + convertToString(edge.outVertex()) + "," + convertToString(edge.label())
                    + "," + convertToString(edge.inVertex()) + ")";
        } else {
            final VertexProperty vertexProperty = (VertexProperty) object;
            return "VertexProperty(" + id + "," + convertToString(vertexProperty.label()) + ","
                    + convertToString(vertexProperty.value()) + "," + convertToString(vertexProperty.element())
                    + ")";
        }
    } else if (object instanceof Lambda)
        return convertLambdaToString((Lambda) object);
    else
        return null == object ? "None" : object.toString();
}

From source file:org.kuali.kfs.module.purap.document.authorization.PurchaseOrderAccountingLineAuthorizer.java

/**
 * Allow new lines to be rendered at NewUnorderedItems node
 * @see org.kuali.kfs.sys.document.authorization.AccountingLineAuthorizerBase#renderNewLine(org.kuali.kfs.sys.document.AccountingDocument, java.lang.String)
 *///from w w w  . ja va  2 s . c  om
@Override
public boolean renderNewLine(AccountingDocument accountingDocument, String accountingGroupProperty) {
    WorkflowDocument workflowDocument = ((PurchasingAccountsPayableDocument) accountingDocument)
            .getFinancialSystemDocumentHeader().getWorkflowDocument();

    Set<String> currentRouteNodeName = workflowDocument.getCurrentNodeNames();

    //  if its in the NEW_UNORDERED_ITEMS node, then allow the new line to be drawn
    if (CollectionUtils.isNotEmpty(currentRouteNodeName)
            && PurchaseOrderAccountingLineAuthorizer.NEW_UNORDERED_ITEMS_NODE
                    .equals(currentRouteNodeName.toString())) {
        return true;
    }

    if (PurapConstants.PurchaseOrderDocTypes.PURCHASE_ORDER_AMENDMENT_DOCUMENT
            .equals(workflowDocument.getDocumentTypeName()) && StringUtils.isNotBlank(accountingGroupProperty)
            && accountingGroupProperty.contains(PurapPropertyConstants.ITEM)) {
        //KFSMI-8961: The accounting line should be addable in the new items as well as
        //existing items in POA..
        //    int itemNumber = determineItemNumberFromGroupProperty(accountingGroupProperty);
        //    PurchaseOrderAmendmentDocument poaDoc = (PurchaseOrderAmendmentDocument) accountingDocument;
        //    List <PurchaseOrderItem> items = poaDoc.getItems();
        //     PurchaseOrderItem item = items.get(itemNumber);
        //    return item.isNewItemForAmendment() || item.getSourceAccountingLines().size() == 0;
        return true;
    }

    return super.renderNewLine(accountingDocument, accountingGroupProperty);
}

From source file:com.abixen.platform.service.businessintelligence.multivisualisation.application.service.database.AbstractDatabaseService.java

private StringBuilder buildQueryForDataSourceData(DatabaseDataSource databaseDataSource,
        Set<String> chartColumnsSet, ResultSetMetaData resultSetMetaData, Integer limit) throws SQLException {
    StringBuilder stringBuilder = new StringBuilder("SELECT ");
    stringBuilder.append(chartColumnsSet.toString().substring(1, chartColumnsSet.toString().length() - 1));
    stringBuilder.append(" FROM ");
    stringBuilder.append(databaseDataSource.getTable());
    stringBuilder.append(" WHERE ");
    stringBuilder/* w w w  .j  a  v a 2  s  .  c om*/
            .append(jsonFilterService.convertJsonToJpql(databaseDataSource.getFilter(), resultSetMetaData));
    return limit != null ? setLimitConditionForCharDataQuery(stringBuilder, limit) : stringBuilder;
}

From source file:org.primeframework.mvc.parameter.RequestBodyWorkflowTest.java

private String keyDiff(Map<String, String[]> actual, Map<String, String[]> expected) {
    Set<String> finalSet = new HashSet<>();
    finalSet.addAll(actual.keySet());//ww  w  .  j  ava  2  s  . c o m
    finalSet.removeAll(expected.keySet());
    finalSet.addAll(expected.keySet());
    finalSet.removeAll(actual.keySet());
    return finalSet.toString();
}

From source file:org.cloudgraph.hbase.graph.GraphSliceAssembler.java

@Override
protected void assemble(PlasmaDataObject target, long targetSequence, EdgeReader sourceCollection,
        PlasmaDataObject source, PlasmaProperty sourceProperty, RowReader rowReader, int level)
        throws IOException {
    Set<Property> props = this.getProperties(target, source, sourceProperty, level);
    if (props.size() == 0)
        return;/*from ww w  . ja va 2 s.  com*/
    if (log.isDebugEnabled())
        log.debug("assembling(" + level + "): " + target.toString() + ": " + props.toString());

    assembleData(target, targetSequence, props, rowReader);

    TableReader tableReader = rowReader.getTableReader();
    TableMapping tableConfig = tableReader.getTableConfig();

    // reference props
    for (Property p : props) {
        PlasmaProperty prop = (PlasmaProperty) p;
        if (prop.getType().isDataType())
            continue;

        EdgeReader edgeReader = null;
        if (rowReader.edgeExists((PlasmaType) target.getType(), prop, targetSequence)) {
            edgeReader = rowReader.getEdgeReader((PlasmaType) target.getType(), prop, targetSequence);
        } else
            continue; // edge not found in data

        PlasmaType childType = (PlasmaType) prop.getType();

        // NOTE: can we have predicates on singular props?
        Where where = this.selection.getPredicate(prop);

        // boolean external = isExternal(edges, rowReader);
        if (!edgeReader.isExternal()) {
            // List<Long> sequences = edgeReader.getSequences();
            Set<Long> sequences = null;
            if (prop.isMany() && where != null) {
                sequences = this.slice.fetchSequences((PlasmaType) prop.getType(), where, rowReader,
                        edgeReader);
                if (sequences.size() > 0) {
                    // preload properties for the NEXT level into the current
                    // row so we have something to assemble
                    Set<Property> childProperies = this.selection.getInheritedProperties(prop.getType(),
                            level + 1);
                    this.slice.loadBySequenceList(sequences, childProperies, childType, rowReader, edgeReader);
                }
            } else {
                // preload properties for the NEXT level into the current
                // row so we have something to assemble
                sequences = new HashSet<Long>();
                for (Long seq : edgeReader.getSequences())
                    sequences.add(seq);
                if (sequences.size() > 0) {
                    Set<Property> childProperies = this.selection.getInheritedProperties(prop.getType(),
                            level + 1);
                    this.slice.loadBySequenceList(sequences, childProperies, childType, rowReader, edgeReader);
                }
            }
            if (sequences.size() > 0) {
                assembleEdges(target, targetSequence, prop, edgeReader, sequences, rowReader,
                        rowReader.getTableReader(), rowReader, level);
            }
        } else {
            String childTable = edgeReader.getTable();
            TableReader externalTableReader = distributedReader.getTableReader(childTable);

            if (log.isDebugEnabled())
                if (!tableConfig.getName().equals(externalTableReader.getTableConfig().getName()))
                    log.debug("switching row context from table: '" + tableConfig.getName() + "' to table: '"
                            + externalTableReader.getTableConfig().getName() + "'");
            List<CellValues> resultRows = null;
            if (where != null) {
                resultRows = this.slice.filter(childType, level, edgeReader, where, rowReader,
                        externalTableReader);
            } else {
                resultRows = edgeReader.getRowValues();
            }
            assembleExternalEdges(target, targetSequence, prop, edgeReader, rowReader, resultRows,
                    externalTableReader, level);
        }
    }
}

From source file:acromusashi.stream.component.rabbitmq.RabbitmqClusterContext.java

/**
 * RabbitMQ?RabbitMQ????????/*w w  w.  j a va  2s  .  c om*/
 * 
 * @param mqProcessList RabbitMQ
 * @param connectionProcessMap ?RabbitMQ?
 * @throws RabbitmqCommunicateException RabbitMQ?RabbitMQ???????
 */
private void validateProcessReference(List<String> mqProcessList, Map<String, String> connectionProcessMap)
        throws RabbitmqCommunicateException {
    //RabbitMQ?????
    if (mqProcessList == null || mqProcessList.size() == 0) {
        String message = "ProcessList is not defined.";
        throw new RabbitmqCommunicateException(message);
    }

    // ?RabbitMQ?????????
    if (connectionProcessMap == null || connectionProcessMap.size() == 0) {
        return;
    }

    Set<String> processSet = new HashSet<String>(mqProcessList);
    Set<String> connectionProcessSet = new HashSet<String>(connectionProcessMap.values());

    if (processSet.containsAll(connectionProcessSet) == false) {
        @SuppressWarnings("unchecked")
        Set<String> nonContainedProcessSet = new HashSet<String>(
                CollectionUtils.subtract(connectionProcessSet, processSet));
        String messageFmt = "Connection process is illegal. NonContainedProcessSet={0}";
        String message = MessageFormat.format(messageFmt, nonContainedProcessSet.toString());
        throw new RabbitmqCommunicateException(message);
    }
}

From source file:com.oneops.transistor.util.CloudUtil.java

private Map<String, TreeSet<String>> getMissingCloudServices(String cloud, Set<String> cloudServices,
        Set<String> requiredServices) {
    Map<String, TreeSet<String>> missingCloud2Services = new TreeMap<>();
    requiredServices.stream().filter(s -> !cloudServices.contains(s))
            .forEach(s -> missingCloud2Services.computeIfAbsent(cloud, k -> new TreeSet<>()).add(s));
    logger.debug("cloud: " + cloud + " required services:: " + requiredServices.toString() + " missingServices "
            + missingCloud2Services.keySet());

    return missingCloud2Services;
}

From source file:org.apache.hive.ptest.conf.TestParser.java

private List<TestBatch> parseTests() {
    Splitter splitter = Splitter.on(" ").trimResults().omitEmptyStrings();
    Context unitContext = new Context(context.getSubProperties(Joiner.on(".").join("unitTests", "")));
    Set<String> excluded = Sets.newHashSet(splitter.split(unitContext.getString("exclude", "")));
    Set<String> isolated = Sets.newHashSet(splitter.split(unitContext.getString("isolate", "")));
    Set<String> included = Sets.newHashSet(splitter.split(unitContext.getString("include", "")));
    if (!included.isEmpty() && !excluded.isEmpty()) {
        throw new IllegalArgumentException(
                String.format("Included and excluded mutally exclusive." + " Included = %s, excluded = %s",
                        included.toString(), excluded.toString()));
    }//  ww  w  .j av a 2  s .  co m
    List<File> unitTestsDirs = Lists.newArrayList();
    for (String unitTestDir : Splitter.on(" ").omitEmptyStrings()
            .split(checkNotNull(unitContext.getString("directories"), "directories"))) {
        File unitTestParent = new File(sourceDirectory, unitTestDir);
        if (unitTestParent.isDirectory()) {
            unitTestsDirs.add(unitTestParent);
        } else {
            LOG.warn("Unit test directory " + unitTestParent + " does not exist.");
        }
    }
    List<TestBatch> result = Lists.newArrayList();
    for (QFileTestBatch test : parseQFileTests()) {
        result.add(test);
        excluded.add(test.getDriver());
    }
    for (File unitTestDir : unitTestsDirs) {
        for (File classFile : FileUtils.listFiles(unitTestDir, new String[] { "class" }, true)) {
            String className = classFile.getName();
            LOG.debug("In  " + unitTestDir + ", found " + className);
            if (className.startsWith("Test") && !className.contains("$")) {
                String testName = className.replaceAll("\\.class$", "");
                if (excluded.contains(testName)) {
                    LOG.info("Exlcuding unit test " + testName);
                } else if (included.isEmpty() || included.contains(testName)) {
                    if (isolated.contains(testName)) {
                        LOG.info("Executing isolated unit test " + testName);
                        result.add(new UnitTestBatch(testName, false));
                    } else {
                        LOG.info("Executing parallel unit test " + testName);
                        result.add(new UnitTestBatch(testName, true));
                    }
                }
            }
        }
    }
    return result;
}

From source file:act.installer.bing.BingSearchRanker.java

/**
 * Updates a TSV row (actually a Map from header to value) with InChI, names and usage information.
 * @param o BasicDBObject containing InChI, and xrefs.{BING, CHEBI, WIKIPEDIA} info
 * @param row TSV row (map from TSV header to value) to be updated
 *//*from   ww w  .j a v  a 2s.c  om*/
private void updateRowWithChemicalInformation(BasicDBObject o, Map<String, String> row) {
    String inchi = o.get("InChI").toString();
    row.put(BingRankerHeaderFields.INCHI.name(), inchi);
    BasicDBObject xref = (BasicDBObject) o.get("xref");
    BasicDBObject bing = (BasicDBObject) xref.get("BING");
    BasicDBObject bingMetadata = (BasicDBObject) bing.get("metadata");
    row.put(BingRankerHeaderFields.BEST_NAME.name(), bingMetadata.get("best_name").toString());
    row.put(BingRankerHeaderFields.TOTAL_COUNT_SEARCH_RESULTS.name(),
            bingMetadata.get("total_count_search_results").toString());
    NamesOfMolecule namesOfMolecule = mongoDB.getNamesFromBasicDBObject(o);
    Set<String> names = namesOfMolecule.getAllNames();
    row.put(BingRankerHeaderFields.ALL_NAMES.name(), names.toString());
    if (includeChebiApplications) {
        BasicDBObject chebi = (BasicDBObject) xref.get("CHEBI");
        if (chebi != null) {
            BasicDBObject chebiMetadata = (BasicDBObject) chebi.get("metadata");
            BasicDBObject chebiApplications = (BasicDBObject) chebiMetadata.get("applications");
            if (chebiApplications != null) {
                row.put(BingRankerHeaderFields.CHEBI_MAIN_APPLICATIONS.name(),
                        chebiApplications.get("main_applications").toString());
                row.put(BingRankerHeaderFields.CHEBI_DIRECT_APPLICATIONS.name(),
                        chebiApplications.get("direct_applications").toString());
            } else {
                LOGGER.debug("ChEBI cross-reference found, but no ChEBI applications for %s", inchi);
                row.put(BingRankerHeaderFields.CHEBI_MAIN_APPLICATIONS.name(), EMPTY_STRING);
                row.put(BingRankerHeaderFields.CHEBI_DIRECT_APPLICATIONS.name(), EMPTY_STRING);
            }
        } else {
            LOGGER.debug("No ChEBI cross-reference found for %s", inchi);
        }
    }
    if (includeWikipediaUrl) {
        BasicDBObject wikipedia = (BasicDBObject) xref.get("WIKIPEDIA");
        if (wikipedia != null) {
            row.put(BingRankerHeaderFields.WIKIPEDIA_URL.name(), wikipedia.get("dbid").toString());
        } else {
            LOGGER.debug("No Wikipedia cross-reference found for %s", inchi);
            row.put(BingRankerHeaderFields.WIKIPEDIA_URL.name(), EMPTY_STRING);
        }
    }
    if (includeUsageExplorerUrl) {
        row.put(BingRankerHeaderFields.USAGE_EXPLORER_URL.name(), getUsageExplorerURLStringFromInchi(inchi));
    }
}

From source file:org.apache.maven.index.FullIndexNexusIndexerTest.java

public void testBrokenJar() throws Exception {
    Query q = nexusIndexer.constructQuery(MAVEN.ARTIFACT_ID, "brokenjar", SearchType.SCORED);

    FlatSearchRequest searchRequest = new FlatSearchRequest(q);

    FlatSearchResponse response = nexusIndexer.searchFlat(searchRequest);

    Set<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());

    ArtifactInfo ai = r.iterator().next();

    assertEquals("brokenjar", ai.getGroupId());
    assertEquals("brokenjar", ai.getArtifactId());
    assertEquals("1.0", ai.getVersion());
    assertEquals(null, ai.getClassNames());
}