Search in sources :

Example 31 with Joiner

use of com.google.common.base.Joiner in project gradle by gradle.

the class DefaultLibraryResolutionErrorMessageBuilder method noCompatibleVariantErrorMessage.

@Override
public String noCompatibleVariantErrorMessage(String libraryName, Iterable<? extends Binary> allBinaries) {
    HashMultimap<String, String> variantAxisMessages = HashMultimap.create();
    for (Binary binary : allBinaries) {
        BinarySpec spec = (BinarySpec) binary;
        VariantsMetaData md = DefaultVariantsMetaData.extractFrom(spec, schemaStore.getSchema(((BinarySpecInternal) spec).getPublicType()));
        Set<String> variantAxesWithIncompatibleTypes = VariantsMetaDataHelper.determineAxesWithIncompatibleTypes(variantsMetaData, md, variantAxesToResolve);
        for (String variantAxis : variantAxesToResolve) {
            String value = md.getValueAsString(variantAxis);
            if (value != null) {
                String message = String.format("'%s'", value);
                if (variantAxesWithIncompatibleTypes.contains(variantAxis)) {
                    message = String.format("%s but with an incompatible type (expected '%s' was '%s')", message, variantsMetaData.getVariantAxisType(variantAxis).getConcreteClass().getName(), md.getVariantAxisType(variantAxis).getConcreteClass().getName());
                }
                variantAxisMessages.put(variantAxis, message);
            }
        }
    }
    Joiner joiner = Joiner.on(", ").skipNulls();
    StringBuilder error = new StringBuilder(String.format(TextUtil.toPlatformLineSeparators("Cannot find a compatible variant for library '%s'.\n"), libraryName));
    for (String variantAxis : variantAxesToResolve) {
        String axisName = renderAxisName(variantAxis);
        error.append("    Required ").append(axisName).append(" '").append(variantsMetaData.getValueAsString(variantAxis)).append("'");
        Set<String> available = new TreeSet<String>(variantAxisMessages.get(variantAxis));
        if (!available.isEmpty()) {
            error.append(", available: ").append(joiner.join(available)).append("\n");
        } else {
            error.append(" but no compatible variant was found\n");
        }
    }
    return error.toString();
}
Also used : Joiner(com.google.common.base.Joiner) BinarySpecInternal(org.gradle.platform.base.internal.BinarySpecInternal) TreeSet(java.util.TreeSet) Binary(org.gradle.platform.base.Binary) BinarySpec(org.gradle.platform.base.BinarySpec)

Example 32 with Joiner

use of com.google.common.base.Joiner in project titan by thinkaurelius.

the class CsvConsumer method accept.

public synchronized void accept(Result r) throws IOException {
    Joiner j = Joiner.on(separator);
    List<String> fields = new ArrayList<String>(Column.values().length);
    for (Column c : Column.values()) {
        fields.add(c.get(r));
    }
    csv.write(String.format("%s%n", j.join(fields)));
    log.debug("Wrote {} to {}", r, csvFile);
    csv.flush();
}
Also used : Joiner(com.google.common.base.Joiner) ArrayList(java.util.ArrayList)

Example 33 with Joiner

use of com.google.common.base.Joiner in project titan by thinkaurelius.

the class CsvConsumer method printHeader.

private synchronized void printHeader() throws IOException {
    long len = csvFile.length();
    if (0 != len) {
        log.debug("Not writing header to {}; file has non-zero length {}", csvFile, len);
        return;
    }
    Joiner j = Joiner.on(separator);
    List<String> headers = new ArrayList<String>(Column.values().length);
    for (Column c : Column.values()) {
        headers.add(c.getName());
    }
    csv.write(String.format("%s%n", j.join(headers)));
    log.debug("Wrote header to {}", csvFile);
    csv.flush();
}
Also used : Joiner(com.google.common.base.Joiner) ArrayList(java.util.ArrayList)

Example 34 with Joiner

use of com.google.common.base.Joiner in project commons by twitter.

the class UrlHelper method getDomainLevels.

/**
   * Gets the domain levels for a host.
   * For example, sub1.sub2.domain.co.uk would return
   * [sub1.sub2.domain.co.uk, sub2.domain.co.uk, domain.co.uk, co.uk, uk].
   *
   *
   * @param host The host to peel subdomains off from.
   * @return The domain levels in this host.
   */
public static List<String> getDomainLevels(String host) {
    Preconditions.checkNotNull(host);
    // Automatically include www prefix if not present.
    if (!host.startsWith("www")) {
        host = "www." + host;
    }
    Joiner joiner = Joiner.on(".");
    List<String> domainParts = Lists.newLinkedList(Arrays.asList(host.split("\\.")));
    List<String> levels = Lists.newLinkedList();
    while (!domainParts.isEmpty()) {
        levels.add(joiner.join(domainParts));
        domainParts.remove(0);
    }
    return levels;
}
Also used : Joiner(com.google.common.base.Joiner)

Example 35 with Joiner

use of com.google.common.base.Joiner in project stargate-core by tuplejump.

the class IndexTestBase method pattern.

protected String pattern(String[] refs, boolean[] optional, boolean[] repeat) {
    Joiner joiner = Joiner.on(",\n");
    String template = "{ref:\"%s\",optional:\"%s\",repeat:\"%s\"}";
    List<String> steps = new ArrayList<>(refs.length);
    for (int i = 0; i < refs.length; i++) {
        steps.add(String.format(template, refs[i], optional[i], repeat[i]));
    }
    return "pattern:{steps:[\n" + joiner.join(steps) + "\n]}";
}
Also used : Joiner(com.google.common.base.Joiner)

Aggregations

Joiner (com.google.common.base.Joiner)47 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)6 IOException (java.io.IOException)5 Map (java.util.Map)4 BufferedWriter (java.io.BufferedWriter)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 ResultSet (com.google.cloud.spanner.ResultSet)2 Statement (com.google.cloud.spanner.Statement)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 DBException (com.yahoo.ycsb.DBException)2 File (java.io.File)2 URI (java.net.URI)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)2 FileLineDifferenceIterator (org.apache.jackrabbit.oak.commons.FileIOUtils.FileLineDifferenceIterator)2 CConfiguration (co.cask.cdap.common.conf.CConfiguration)1