Example usage for java.util.stream Collectors joining

List of usage examples for java.util.stream Collectors joining

Introduction

In this page you can find the example usage for java.util.stream Collectors joining.

Prototype

public static Collector<CharSequence, ?, String> joining(CharSequence delimiter, CharSequence prefix,
        CharSequence suffix) 

Source Link

Document

Returns a Collector that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.

Usage

From source file:nc.noumea.mairie.appock.viewmodel.EditStockReferentServiceViewModel.java

private void importerStockXlsx(Media media) {
    try {//from   www. ja  v  a2 s  .  c om
        List<String> warnings = StockSpreadsheetImporter.importFromXls(authHelper.getCurrentUser().getService(),
                stockService, media.getStreamData());
        if (!CollectionUtils.isEmpty(warnings)) {
            Messagebox.show( //
                    "Certaines rfrences ont t ignores :\n"
                            + warnings.stream().collect(Collectors.joining("\n - ", " - ", "")), //
                    "Attention", //
                    Messagebox.OK, //
                    Messagebox.EXCLAMATION);
        }
    } catch (Exception e) {
        log.error("An error accored during stock xlsx import : " + e.getMessage(), e);
        Messagebox.show("Une erreur s'est produite durant l'import Excel.", "Import chou", Messagebox.OK,
                Messagebox.ERROR);
        return;
    }
    showNotificationStandard("Inventaire import");
}

From source file:com.diversityarrays.kdxplore.field.CollectionPathSetupDialog.java

public void setOnlyAllow(PlotsPerGroup ppg, OrOrTr... orts) {
    OrOrTr first = orts[0];/*from  ww w  .jav a2 s.co m*/
    odtChoicePanel.setOnlyAllow(orts);
    setOrOrTr(first, ppg);

    String msg;
    if (orts.length == 1) {
        msg = "<HTML>For now, only supporting:<BR>" + orts[0].toString();
    } else {
        msg = Arrays.asList(orts).stream().map(oot -> oot.toString())
                .collect(Collectors.joining("<BR>", "<HTML>For now, only supporting:<BR>", ""));
    }

    JLabel label = new JLabel(msg, JLabel.CENTER);
    label.setForeground(Color.RED);
    getContentPane().add(label, BorderLayout.NORTH);
    //        setGlassPane(label);
    //        label.setVisible(true);
}

From source file:org.apache.james.jmap.methods.integration.cucumber.GetMessagesMethodStepdefs.java

@When("^the user is getting his messages with parameters$")
public void postWithParameters(DataTable parameters) throws Throwable {
    String payload = parameters.asMap(String.class, String.class).entrySet().stream().map(this::entryToPair)
            .map(this::quoteIndex).map(this::joinKeyValue).collect(Collectors.joining(",", "{", "}"));

    post("[[\"getMessages\", " + payload + ", \"#0\"]]");
}

From source file:ddf.catalog.source.solr.SolrFilterDelegate.java

@Override
public SolrQuery propertyIsFuzzy(String propertyName, String searchPhrase) {
    // On fuzzy searches, no text analysis is performed on the search phrase. Expect fuzzy
    // terms to be case insensitive.
    String fuzzyPhrase = Stream.of(StringUtils.split(searchPhrase)).map(String::toLowerCase)
            .collect(Collectors.joining("~ +", "(+", "~)"));

    if (Metacard.ANY_TEXT.equals(propertyName)) {
        return new SolrQuery(anyTextSolrQuery(fuzzyPhrase, false));
    } else {/* ww  w. java  2s.c o m*/
        String mappedPropertyName = getMappedPropertyName(propertyName, AttributeFormat.STRING, false);

        return new SolrQuery(mappedPropertyName + ":" + fuzzyPhrase);
    }
}

From source file:com.excelsiorjet.api.util.Utils.java

/**
 * @return String in format "([groupId],[artifactId],[version], [path])" (all fields are optional)
 *///from w w w . j av a 2  s .  c o  m
public static String idStr(String groupId, String artifactId, String version, File path) {
    return Stream.of(groupId, artifactId, version, path == null ? null : getCanonicalPath(path))
            .filter(item -> item != null).collect(Collectors.joining(":", "(", ")"));
}

From source file:com.nike.cerberus.server.config.guice.CmsGuiceModule.java

@Provides
@Singleton//from   w w  w . j  av a  2 s .  com
public CodahaleMetricsListener metricsListener(
        @Named("metrics.slf4j.reporting.enabled") boolean slf4jReportingEnabled,
        @Named("metrics.jmx.reporting.enabled") boolean jmxReportingEnabled,
        @Named("graphite.url") String graphiteUrl, @Named("graphite.port") int graphitePort,
        @Named("graphite.reporting.enabled") boolean graphiteEnabled,
        @Named("appInfoFuture") CompletableFuture<AppInfo> appInfoFuture,
        CodahaleMetricsCollector metricsCollector) {
    List<ReporterFactory> reporters = new ArrayList<>();

    if (slf4jReportingEnabled)
        reporters.add(new DefaultSLF4jReporterFactory());

    if (jmxReportingEnabled)
        reporters.add(new DefaultJMXReporterFactory());

    if (graphiteEnabled) {
        AppInfo appInfo = appInfoFuture.join();
        String graphitePrefix = appInfo.appId() + "." + appInfo.dataCenter() + "." + appInfo.environment() + "."
                + appInfo.instanceId();
        reporters.add(new DefaultGraphiteReporterFactory(graphitePrefix, graphiteUrl, graphitePort));
    }

    if (reporters.isEmpty()) {
        logger.info("No metrics reporters enabled - disabling metrics entirely.");
        return null;
    }

    String metricReporterTypes = reporters.stream().map(rf -> rf.getClass().getSimpleName())
            .collect(Collectors.joining(",", "[", "]"));
    logger.info("Metrics enabled. metric_reporter_types={}", metricReporterTypes);

    CodahaleMetricsEngine metricsEngine = new CodahaleMetricsEngine(metricsCollector, reporters);
    metricsEngine.start();
    return new CodahaleMetricsListener(metricsCollector);
}

From source file:ch.dissem.bitmessage.demo.Application.java

private void show(Plaintext message) {
    System.out.println();/*w w  w. j  a v a  2 s  .c  o m*/
    System.out.println("From:    " + message.getFrom());
    System.out.println("To:      " + message.getTo());
    System.out.println("Subject: " + message.getSubject());
    System.out.println();
    System.out.println(WordUtils.wrap(message.getText(), 120));
    System.out.println();
    System.out.println(message.getLabels().stream().map(Label::toString)
            .collect(Collectors.joining(", ", "Labels: ", "")));
    System.out.println();
    ctx.labeler().markAsRead(message);
    ctx.messages().save(message);
    String command;
    do {
        System.out.println("r) reply");
        System.out.println("d) delete");
        System.out.println("a) archive");
        System.out.println(COMMAND_BACK);
        command = commandLine.nextCommand();
        switch (command) {
        case "r":
            compose(message.getTo(), message.getFrom(), "RE: " + message.getSubject());
            break;
        case "d":
            ctx.labeler().delete(message);
            ctx.messages().save(message);
            return;
        case "a":
            ctx.labeler().archive(message);
            ctx.messages().save(message);
            return;
        case "b":
            return;
        default:
            System.out.println(ERROR_UNKNOWN_COMMAND);
        }
    } while (!"b".equalsIgnoreCase(command));
}

From source file:com.evolveum.midpoint.model.impl.lens.projector.PolicyRuleProcessor.java

private String computeAssignmentInfo(AssignmentPath path, PrismObject<?> defaultObject) {
    if (path == null) {
        return String.valueOf(defaultObject); // shouldn't occur
    }/*from w w  w . j  a va2  s  . c o m*/
    List<ObjectType> objects = path.getFirstOrderChain();
    if (objects.isEmpty()) { // shouldn't occur
        return String.valueOf(defaultObject);
    }
    ObjectType last = objects.get(objects.size() - 1);
    StringBuilder sb = new StringBuilder();
    sb.append(last);
    if (objects.size() > 1) {
        sb.append(objects.stream().map(o -> PolyString.getOrig(o.getName()))
                .collect(Collectors.joining("->", " (", ")")));
    }
    return sb.toString();
}