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();
}
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();
}
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();
}
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;
}
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]}";
}
Aggregations