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:com.thoughtworks.go.config.exceptions.ElasticAgentsResourceUpdateException.java

public ElasticAgentsResourceUpdateException(List<String> elasticAgents) {
    super(String.format("Can not update resources on Elastic Agents [%s]",
            StringUtils.join(elasticAgents, ", ")));
}

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

public static void test(Subscription subscription) throws Exception {
    // List size names in a specific region
    Set<String> sizeNames = subscription.sizes().asMap("westus").keySet();
    System.out.println("VM sizes: \n\t" + StringUtils.join(sizeNames, ",\n\t"));

    // List sizes in a specific region
    Map<String, Size> sizes = subscription.sizes().asMap("westus");
    for (Size size : sizes.values()) {
        System.out.println(String.format(
                "VM size: %s\n" + "\tMax data disk count: %d\n" + "\tMemory in MB: %d\n"
                        + "\tNumber of cores: %d\n" + "\tOS disk size in MB: %d\n"
                        + "\tResource disk size in MB: %d\n",
                size.id(), size.maxDataDiskCount(), size.memoryInMB(), size.numberOfCores(),
                size.osDiskSizeInMB(), size.resourceDiskSizeInMB()));
    }//w  ww.  j av  a  2  s.c  o m
}

From source file:com.blackducksoftware.integration.hub.detect.workflow.codelocation.FileNameUtils.java

public static String relativize(final String from, final String to) {
    String relative = to;/*from   w w  w  .j av  a 2  s .  c o m*/
    try {
        final Path toPath = new File(to).toPath();
        final Path fromPath = new File(from).toPath();
        final Path fromParentPath = fromPath.getParent();
        final Path relativePath = fromParentPath.relativize(toPath);
        final List<String> relativePieces = new ArrayList<>();
        for (int i = 0; i < relativePath.getNameCount(); i++) {
            relativePieces.add(relativePath.getName(i).toFile().getName());
        }
        relative = StringUtils.join(relativePieces, "/");
    } catch (final Exception e) {
        logger.info(String.format("Unable to relativize path, full source path will be used: %s", to));
        logger.debug("The reason relativize failed: ", e);
    }

    return relative;
}

From source file:com.thoughtworks.go.config.exceptions.InvalidPendingAgentOperationException.java

public InvalidPendingAgentOperationException(List<String> allPendingAgents) {
    super(String.format("Invalid operation performed on pending agents: [%s]",
            StringUtils.join(allPendingAgents, ", ")));
}

From source file:com.webbfontaine.valuewebb.irms.action.ActionDefConverter.java

public Hits action2Hits(ActionDef actionDef) {
    RuleContext ruleContext = actionDef.getRuleContext();

    Hits hits = new Hits();
    hits.setTtId(ruleContext.getDocumentId());
    hits.setCriteriaId(ruleContext.getRuleId());
    hits.setCriteriaCode(ruleContext.getRuleCode());
    hits.setCriteriaName(ruleContext.getRuleName());
    hits.setOperation(ruleContext.getOperation());
    hits.setAction(actionDef.getName());
    hits.setRecipient(StringUtils.join(actionDef.getRecipients(), ','));
    hits.setMessage(actionDef.getMessage());
    hits.setHitDateTime(new Date());

    return hits;/*from   w w w  .  j  av  a2 s.com*/
}

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

public static void test(Subscription subscription) throws Exception {
    // Listing all resource names
    Map<String, Resource> resources = subscription.resources().asMap();
    System.out.println(String.format("Resource ids: %s\n\t", StringUtils.join(resources.keySet(), ",\n\t")));

    // Listing resources in a specific group
    String groupName = "azchat";
    Map<String, Resource> resources2 = subscription.resources().asMap(groupName);
    System.out.println("Resources inside group '" + groupName + "':");
    for (Resource resource : resources2.values()) {
        printResource(resource);/*  ww w.  j a va2s  .  c  o  m*/
    }

    // Getting information about a specific resource based on ID
    Resource resource = subscription.resources(
            "/subscriptions/9657ab5d-4a4a-4fd2-ae7a-4cd9fbd030ef/resourceGroups/javasampleresourcegroup/providers/Microsoft.Storage/storageAccounts/javastojzgsg");
    printResource(resource);

    // Getting information about a specific resource based on name, type, provider and group
    resource = subscription.resources().get(resource.name(), resource.type(), resource.provider(),
            resource.resourceGroup());
    printResource(resource);

    // Delete a resource 
    System.out.println(String.format("Deleting resource '%s' of type '%s' by provider '%s' in group '%s'",
            resource.name(), resource.type(), resource.provider(), resource.resourceGroup()));

    resource.delete();

    // Delete a resource based on its ID
    String resourceToDelete = "ThisMustFail";
    System.out.println("Deleting resource " + resourceToDelete);
    subscription.resources().delete(resourceToDelete);

}

From source file:io.github.robwin.swagger2markup.utils.ParameterUtils.java

public static String getType(Parameter parameter, MarkupLanguage markupLanguage) {
    Validate.notNull(parameter, "property must not be null!");
    String type = "NOT FOUND";
    if (parameter instanceof BodyParameter) {
        BodyParameter bodyParameter = (BodyParameter) parameter;
        Model model = bodyParameter.getSchema();
        type = ModelUtils.getType(model, markupLanguage);
    } else if (parameter instanceof AbstractSerializableParameter) {
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
        List enums = serializableParameter.getEnum();
        if (CollectionUtils.isNotEmpty(enums)) {
            type = "enum" + " (" + StringUtils.join(enums, ", ") + ")";
        } else {/*from  w  ww.jav  a2 s  . c  om*/
            type = getTypeWithFormat(serializableParameter.getType(), serializableParameter.getFormat());
        }
        if (type.equals("array")) {
            String collectionFormat = serializableParameter.getCollectionFormat();
            type = collectionFormat + " "
                    + PropertyUtils.getType(serializableParameter.getItems(), markupLanguage) + " " + type;
        }
    } else if (parameter instanceof RefParameter) {
        RefParameter refParameter = (RefParameter) parameter;
        switch (markupLanguage) {
        case ASCIIDOC:
            return "<<" + refParameter.getSimpleRef() + ">>";
        default:
            return refParameter.getSimpleRef();
        }
    }
    return StringUtils.defaultString(type);
}

From source file:edu.illinois.cs.cogcomp.wikifier.utils.io.CSVAdapter.java

@Override
public String marshal(List<String> v) throws Exception {
    return StringUtils.join(v, ',');
}

From source file:com.eryansky.common.utils.ConvertUtils.java

/**
 * ????(getter), ??.// w  w w.ja  v a 2 s  . c  o  m
 * 
 * @param collection ???.
 * @param propertyName ??????.
 * @param separator .
 */
@SuppressWarnings({ "rawtypes" })
public static String convertElementPropertyToString(final Collection collection, final String propertyName,
        final String separator) {
    List list = convertElementPropertyToList(collection, propertyName);
    return StringUtils.join(list, separator);
}

From source file:com.shirokumacafe.archetype.common.utilities.SimpleMailService.java

/**
 * ??.//from   w  ww.  j a v  a  2 s.c  o  m
 */
public void sendMail(SimpleMailMessage msg) {
    try {
        mailSender.send(msg);
        if (logger.isInfoEnabled()) {
            logger.info("??{}", StringUtils.join(msg.getTo(), ","));
        }
    } catch (Exception e) {
        logger.error("??", e);
    }
}