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:co.cask.tigon.sql.flowlet.AbstractInputFlowlet.java

/**
 * ProcessMonitor callback function//  ww  w  . j  a va2 s.  co  m
 * Restarts SQL Compiler processes
 */
@Override
public void notifyFailure(Set<String> errorProcessNames) {
    if (errorProcessNames != null) {
        LOG.warn("Missing pings from : " + errorProcessNames.toString());
    } else {
        LOG.warn("No heartbeats registered");
    }
    healthInspector.stopAndWait();
    healthInspector = new HealthInspector(this);
    inputFlowletService.restartService(healthInspector);
    healthInspector.startAndWait();
}

From source file:br.ufpa.gercom.mtuldp.store.HostStorageMgm.java

public boolean update(Host host) throws RuntimeException {

    checkNotNull(host, "Host Object cannot be null");

    String UPDATE = "MATCH" + "(a:%s{id:'%s'}) " + "SET " + "a.mac = '%s'," + "a.vlan = '%s'," + "a.ip = %s";

    String type = Host.class.getSimpleName();
    String id = getId(host);//  w w w. j av a 2s  . c  o m
    String mac = host.mac().toString();
    String vlan = host.vlan().toString();
    Set<String> ip = new LinkedHashSet<>();

    host.ipAddresses().forEach(ipAddress -> {
        ip.add("\'" + ipAddress.toString() + "\'");
    });

    String query = String.format(UPDATE, type, id, mac, vlan, ip.toString());

    StatementResult result = driver.executeCypherQuery(query);
    ResultSummary summary = result.consume();

    if (!summary.counters().containsUpdates()) {
        log.error("Host id ({}) cannot be updated, data is not different or transaction error");
        return false;
    }

    log.info("Host id ({}) was updated", id);
    return true;
}

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

/**
 * Allow new lines to be rendered at NewUnorderedItems node
 *
 * @see org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#renderNewLine(org.kuali.ole.sys.document.AccountingDocument, java.lang.String)
 *///from  w  ww.  jav  a 2  s.com
@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 (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)) {
        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 super.renderNewLine(accountingDocument, accountingGroupProperty);
}

From source file:br.ufpa.gercom.mtuldp.store.HostStorageMgm.java

public boolean create(Host host) throws RuntimeException {

    checkNotNull(host, "Host Object cannot be null");

    String CREATE = "MERGE" + "(a:%s" + "{" + "id:'%s', " + "host_id:'%s'," + "mac:'%s'," + "ip:%s,"
            + "vlan:'%s'" + "})";

    String id = getId(host);/* w w  w. j  av a2  s.  c  o m*/
    String type = Host.class.getSimpleName();
    String host_id = host.id().toString();
    String mac = host.mac().toString();
    String vlan = host.vlan().toString();
    Set<String> ip = new LinkedHashSet<>();

    host.ipAddresses().forEach(ipAddress -> {
        ip.add("\'" + ipAddress.toString() + "\'");
    });

    String query = String.format(CREATE, type, host_id, mac, ip.toString(), vlan);

    StatementResult result = driver.executeCypherQuery(query);
    ResultSummary summary = result.consume();

    if (summary.counters().nodesCreated() == 0) {
        log.error("Host id ({}) cannot be create by host already exists or error transaction", host_id);
        return false;
    }

    log.info("Host id ({}) had created with sucessfully", host_id);
    return true;
}

From source file:com.github.alexfalappa.nbspringboot.codegen.InjectSpringBootGenerator.java

private void addDeps(String bootVersion, final Set<String> selectedDeps) throws Exception {
    logger.log(Level.INFO, "Adding Spring Boot dependencies: {0}", selectedDeps.toString());
    JsonNode depsMeta = InitializrService.getInstance().getDependencies(bootVersion);
    Iterator<Map.Entry<String, JsonNode>> it = depsMeta.path("dependencies").fields();
    int newPos = component.getCaretPosition();
    try {/*  w ww  .j  av a  2s.c  o m*/
        if (model.startTransaction()) {
            DependencyContainer container = model.getProject();
            // iterate on "dependencies" JSON object (fields are dependency ids)
            while (it.hasNext()) {
                Map.Entry<String, JsonNode> entry = it.next();
                if (selectedDeps.contains(entry.getKey())) {
                    JsonNode depInfo = entry.getValue();
                    String groupId = depInfo.path("groupId").asText();
                    String artifactId = depInfo.path("artifactId").asText();
                    String scope = depInfo.path("scope").asText();
                    Dependency dep = container.findDependencyById(groupId, artifactId, null);
                    if (dep == null) {
                        dep = model.getFactory().createDependency();
                        dep.setGroupId(groupId);
                        dep.setArtifactId(artifactId);
                        // set scope only if not 'compile'
                        if (!scope.equals("compile")) {
                            if (scope.equals("compileOnly")) {
                                dep.setOptional(Boolean.TRUE);
                            } else {
                                // scope is 'runtime' or 'test'
                                dep.setScope(scope);
                            }
                        }
                        // manage optional version
                        if (depInfo.hasNonNull("version")) {
                            dep.setVersion(depInfo.get("version").asText());
                        }
                        // manage optional need of extra repository
                        if (depInfo.hasNonNull("repository")) {
                            addRepository(depsMeta, depInfo.get("repository").asText());
                            addPluginRepository(depsMeta, depInfo.get("repository").asText());
                        }
                        // manage optional need of BOM inclusion
                        if (depInfo.hasNonNull("bom")) {
                            addBom(depsMeta, depInfo.get("bom").asText());
                        }
                        container.addDependency(dep);
                        newPos = model.getAccess().findPosition(dep.getPeer());
                    }
                }
            }
        }
    } finally {
        try {
            model.endTransaction();
        } catch (IllegalStateException ex) {
            StatusDisplayer.getDefault().setStatusText("Cannot write to the model: " + ex.getMessage(),
                    StatusDisplayer.IMPORTANCE_ERROR_HIGHLIGHT);
        }
    }
    component.setCaretPosition(newPos);
}

From source file:org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator.java

private 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 + "\"")
                .replace("$", "\\$");
    } else if (object instanceof Set) {
        final Set<String> set = new HashSet<>(((Set) object).size());
        for (final Object item : (Set) object) {
            set.add(convertToString(item));
        }/* w w w  .  j  ava2  s .co m*/
        return set.toString() + " as Set";
    } 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("new LinkedHashMap(){{");
        for (final Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
            map.append("put(").append(convertToString(entry.getKey())).append(",")
                    .append(convertToString(entry.getValue())).append(");");
        }
        return map.append("}}").toString();
    } else if (object instanceof Long)
        return object + "L";
    else if (object instanceof Double)
        return object + "d";
    else if (object instanceof Float)
        return object + "f";
    else if (object instanceof Integer)
        return "(int) " + object;
    else if (object instanceof Class)
        return ((Class) object).getCanonicalName();
    else if (object instanceof P)
        return convertPToString((P) object, new StringBuilder()).toString();
    else if (object instanceof SackFunctions.Barrier)
        return "SackFunctions.Barrier." + object.toString();
    else if (object instanceof VertexProperty.Cardinality)
        return "VertexProperty.Cardinality." + object.toString();
    else if (object instanceof TraversalOptionParent.Pick)
        return "TraversalOptionParent.Pick." + object.toString();
    else if (object instanceof Enum)
        return ((Enum) object).getDeclaringClass().getSimpleName() + "." + object.toString();
    else if (object instanceof Element) {
        final String id = convertToString(((Element) object).id());
        String temp = this.traversalSource.equals("__") ? "g" : this.traversalSource;
        if (object instanceof Vertex)
            temp = temp + ".V(" + id + ").next()";
        else if (object instanceof Edge)
            temp = temp + ".E(" + id + ").next()";
        else {
            final VertexProperty vertexProperty = (VertexProperty) object;
            temp = temp + ".V(" + convertToString(vertexProperty.element().id()) + ").properties("
                    + convertToString(vertexProperty.key()) + ").hasId(" + id + ").next()";
        }
        return temp;
    } else if (object instanceof Lambda) {
        final String lambdaString = ((Lambda) object).getLambdaScript().trim();
        return lambdaString.startsWith("{") ? lambdaString : "{" + lambdaString + "}";
    } else if (object instanceof TraversalStrategyProxy) {
        final TraversalStrategyProxy proxy = (TraversalStrategyProxy) object;
        if (proxy.getConfiguration().isEmpty())
            return proxy.getStrategyClass().getCanonicalName() + ".instance()";
        else
            return proxy.getStrategyClass().getCanonicalName()
                    + ".create(new org.apache.commons.configuration.MapConfiguration("
                    + convertToString(ConfigurationConverter.getMap(proxy.getConfiguration())) + "))";
    } else if (object instanceof TraversalStrategy) {
        return convertToString(new TraversalStrategyProxy(((TraversalStrategy) object)));
    } else
        return null == object ? "null" : object.toString();
}

From source file:org.deeplearning4j.nn.modelimport.keras.layers.convolutional.KerasConvolution1D.java

/**
 * Set weights for layer.//from   w  ww  . j a  va  2 s.  c  o m
 *
 * @param weights   Map from parameter name to INDArray.
 */
@Override
public void setWeights(Map<String, INDArray> weights) throws InvalidKerasConfigurationException {
    this.weights = new HashMap<>();
    if (weights.containsKey(conf.getKERAS_PARAM_NAME_W())) {
        INDArray kerasParamValue = weights.get(conf.getKERAS_PARAM_NAME_W());
        INDArray paramValue;
        switch (this.getDimOrder()) {
        case TENSORFLOW:
            paramValue = kerasParamValue.permute(2, 1, 0);
            paramValue = paramValue.reshape(paramValue.size(0), paramValue.size(1), paramValue.size(2), 1);
            break;
        case THEANO:
            paramValue = kerasParamValue
                    .reshape(kerasParamValue.size(0), kerasParamValue.size(1), kerasParamValue.size(2), 1)
                    .dup();
            for (int i = 0; i < paramValue.tensorssAlongDimension(2, 3); i++) {
                INDArray copyFilter = paramValue.tensorAlongDimension(i, 2, 3).dup();
                double[] flattenedFilter = copyFilter.ravel().data().asDouble();
                ArrayUtils.reverse(flattenedFilter);
                INDArray newFilter = Nd4j.create(flattenedFilter, copyFilter.shape());
                INDArray inPlaceFilter = paramValue.tensorAlongDimension(i, 2, 3);
                inPlaceFilter.muli(0).addi(newFilter);
            }
            break;
        default:
            throw new InvalidKerasConfigurationException("Unknown keras backend " + this.getDimOrder());
        }
        this.weights.put(ConvolutionParamInitializer.WEIGHT_KEY, paramValue);
    } else
        throw new InvalidKerasConfigurationException(
                "Parameter " + conf.getKERAS_PARAM_NAME_W() + " does not exist in weights");

    if (hasBias) {
        if (weights.containsKey(conf.getKERAS_PARAM_NAME_B()))
            this.weights.put(ConvolutionParamInitializer.BIAS_KEY, weights.get(conf.getKERAS_PARAM_NAME_B()));
        else
            throw new InvalidKerasConfigurationException(
                    "Parameter " + conf.getKERAS_PARAM_NAME_B() + " does not exist in weights");
    }
    if (weights.size() > 2) {
        Set<String> paramNames = weights.keySet();
        paramNames.remove(conf.getKERAS_PARAM_NAME_W());
        paramNames.remove(conf.getKERAS_PARAM_NAME_B());
        String unknownParamNames = paramNames.toString();
        log.warn("Attemping to set weights for unknown parameters: "
                + unknownParamNames.substring(1, unknownParamNames.length() - 1));
    }
}

From source file:io.cloudslang.lang.compiler.modeller.transformers.SeqStepsTransformer.java

private void validateOnlySupportedKeys(Map<String, String> tMap, Set<String> mandatoryKeys,
        Set<String> optionalKeys) {
    Set<String> invalidKeys = new HashSet<>(tMap.keySet());
    invalidKeys.removeAll(mandatoryKeys);
    invalidKeys.removeAll(optionalKeys);
    if (isNotEmpty(invalidKeys)) {
        throw new RuntimeException(
                SEQ_OPERATION_ILLEGAL_TAGS + invalidKeys.toString() + INVALID_KEYS_ERROR_MESSAGE_SUFFIX);
    }//from   ww  w  .  j  a v a2  s  .  co m
}

From source file:org.jasig.portlet.notice.service.jpa.JpaNotificationService.java

@Override
public NotificationResponse fetch(PortletRequest req) {

    NotificationResponse rslt = EMPTY_RESPONSE; // default

    PortletPreferences prefs = req.getPreferences();

    // We do not perform a check for unauthenticated users (but this
    // is an assumption that may need revisiting in the future).
    if (usernameFinder.isAuthenticated(req) && Boolean.parseBoolean(prefs.getValue(PREFS_ENABLED, "false"))) {
        final String username = usernameFinder.findUsername(req);

        log.debug("Fetching notifications for user:  {}", username);

        final Set<JpaEntry> entries = notificationDao.getEntriesByRecipient(username);

        log.debug("Found the following notifications for user '{}':  {}", username, entries.toString());

        rslt = prepareResponse(entries, username);
    }/*from  ww  w .  j  a  v  a2  s. c  om*/

    return rslt;

}

From source file:org.cloudgraph.hbase.graph.GraphAssembler.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 www .j a v a 2  s.  c o m*/
    if (log.isDebugEnabled())
        log.debug("assembling(" + level + "): " + target + ": " + 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);
        }

        if (edgeReader == null)
            continue; // edge not found in data

        if (!edgeReader.isExternal()) {
            assembleEdges(target, targetSequence, prop, edgeReader, rowReader, tableReader, rowReader, level);
        } else {
            TableReader externalTableReader = distributedReader.getTableReader(edgeReader.getTable());
            if (externalTableReader == null)
                throw new OperationException("no table reader found for type, " + edgeReader.getBaseType());
            assembleExternalEdges(target, targetSequence, prop, edgeReader, rowReader, externalTableReader,
                    level);
        }
    }
}