Example usage for org.apache.commons.lang3 StringUtils join

List of usage examples for org.apache.commons.lang3 StringUtils join

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils join.

Prototype

public static String join(final Iterable<?> iterable, final String separator) 

Source Link

Document

Joins the elements of the provided Iterable into a single String containing the provided elements.

No delimiter is added before or after the list.

Usage

From source file:dev.maisentito.suca.commands.UrbanCommandHandler.java

@Override
public void handleCommand(MessageEvent event, String[] args) throws Throwable {
    List<Definition> defs = UrbanDictionary.define(StringUtils.join(args, ' ')).getList();
    if (!defs.isEmpty()) {
        Definition def = defs.get(0);/* w w w . ja v  a  2 s  .  com*/
        event.respond(String.format("%s: %s", def.getWord(), def.getDefinition()));
    } else {
        event.respond("no results");
    }
}

From source file:com.thoughtworks.go.config.validation.EnvironmentAgentValidator.java

public void validate(CruiseConfig cruiseConfig) {
    List<ConfigErrors> errors = validateConfig(cruiseConfig);
    List<String> errorMessages = new ArrayList<>();
    for (ConfigErrors error : errors) {
        errorMessages.addAll(error.getAll());
    }//from www. j  a va  2s .com
    if (!errors.isEmpty())
        throw new RuntimeException(StringUtils.join(errorMessages, ", "));
}

From source file:io.wcm.wcm.parsys.controller.CssBuilder.java

/**
 * @return CSS string or null if no valid items are defined.
 *///from   w w  w.ja va  2  s. c  o m
public String build() {
    if (items.isEmpty()) {
        return null;
    } else {
        return StringUtils.join(items, " ");
    }
}

From source file:com.it.j2ee.modules.email.SimpleMailService.java

/**
 * ??./*from   w  w w  .  j  a v  a 2s  . c  om*/
 */
public void sendNotificationMail(String userName) {
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setFrom("springside3.demo@gmail.com");
    msg.setTo("springside3.demo@gmail.com");
    msg.setSubject("");

    // ????
    String content = String.format(textTemplate, userName, new Date());
    msg.setText(content);

    try {
        mailSender.send(msg);
        if (logger.isInfoEnabled()) {
            logger.info("??{}", StringUtils.join(msg.getTo(), ","));
        }
    } catch (Exception e) {
        logger.error("??", e);
    }
}

From source file:com.nesscomputing.migratory.migration.sql.SqlScriptSmallTest.java

@Test
public void stripSqlCommentsNoComment() {
    lines.add("select * from table;");
    sqlScript = new SqlScript(StringUtils.join(lines, "\n"));
    final Collection<SqlStatement> statements = sqlScript.getSqlStatements();
    Assert.assertNotNull(statements);/*from  w w w .ja va2s .c o  m*/
    Assert.assertEquals(1, statements.size());
    final Iterator<SqlStatement> it = statements.iterator();
    Assert.assertEquals("select * from table", it.next().getSql());
}

From source file:com.oakhole.core.email.SimpleMailService.java

/**
 * ??.//w ww  .  j  av  a  2s .c  om
 */
public void sendNotificationMail(String userName) {
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setFrom("evilefy@gmail.com");
    msg.setTo("18652023713@wo.com.cn");
    msg.setSubject("");

    // ????
    String content = String.format(textTemplate, userName, new Date());
    msg.setText(content);

    try {
        mailSender.send(msg);
        if (logger.isInfoEnabled()) {
            logger.info("??{}", StringUtils.join(msg.getTo(), ","));
        }
    } catch (Exception e) {
        logger.error("??", e);
    }
}

From source file:gov.nih.nci.caintegrator.domain.application.SegmentDataResultValue.java

/**
 * @return the display list of genes
 */
public String getDisplayGenes() {
    return StringUtils.join(genes, ", ");
}

From source file:com.blackducksoftware.integration.hub.detect.property.PropertyConverter.java

public String convertFromValue(final PropertyType type, final Object objectValue) {
    String displayValue = "";
    if (PropertyType.STRING == type) {
        displayValue = (String) objectValue;
    } else if (PropertyType.STRING_ARRAY == type) {
        displayValue = StringUtils.join((String[]) objectValue, ",");
    } else if (null != objectValue) {
        displayValue = objectValue.toString();
    }/*from   ww  w.  ja  v a2 s .  c  o  m*/
    return displayValue;
}

From source file:com.microsoft.azure.shortcuts.resources.samples.LoadBalancersSample.java

public static void test(Subscription subscription) throws Exception {
    LoadBalancer lb;/*  w ww  .  jav  a 2s . c o  m*/
    String groupName = "lbtestgroup";
    String lbName = "marcinslb";

    // Create a new LB in a new resource group
    lb = subscription.loadBalancers().define(lbName).withRegion(Region.US_WEST).withNewResourceGroup(groupName)
            .withNewPublicIpAddress("marcinstest2").create();

    // Get info about a specific lb using its group and name
    lb = subscription.loadBalancers(lb.id());
    printLB(lb);

    // Listing all lbs
    Map<String, LoadBalancer> lbs = subscription.loadBalancers().asMap();
    System.out.println(String.format("Load Balancer ids: \n\t%s", StringUtils.join(lbs.keySet(), ",\n\t")));

    // Listing lbs in a specific resource group
    lbs = subscription.loadBalancers().asMap(groupName);
    System.out.println(String.format("Load balancer ids in group '%s': \n\t%s", groupName,
            StringUtils.join(lbs.keySet(), ",\n\t")));

    // Get info about a specific lb using its resource ID
    lb = subscription.loadBalancers(lb.resourceGroup(), lb.name());
    printLB(lb);

    // Delete the load balancer
    lb.delete();

    // Create a new lb in an existing resource group
    lb = subscription.loadBalancers().define(lbName + "2").withRegion(Region.US_WEST)
            .withExistingResourceGroup(groupName).withNewPublicIpAddress("marcinstest3").create();

    printLB(lb);

    // Delete the lb
    lb.delete();

    // Delete the group
    subscription.resourceGroups(groupName).delete();
}

From source file:com.salesforce.ide.apex.internal.core.tooling.systemcompletions.model.Constructor.java

@Override
public String getDisplayString() {
    if (StringUtils.isEmpty(name))
        return null;

    StringBuilder sb = new StringBuilder();
    sb.append(name);/*from www.j av a2s . c om*/
    sb.append('(');
    if (parameters != null) {
        sb.append(StringUtils.join(parameters, ","));
    }
    sb.append(')');
    return sb.toString();
}