private static String directionToString(@GridLayoutAnimationControllerDirection int direction) { List<String> parts = new ArrayList<>(); int horizontal = direction & DIRECTION_HORIZONTAL_MASK; int vertical = direction & DIRECTION_VERTICAL_MASK; if ((horizontal & DIRECTION_RIGHT_TO_LEFT) != 0) { parts.add("rightToLeft"); } else { parts.add("leftToRight"); } if ((vertical & DIRECTION_BOTTOM_TO_TOP) != 0) { parts.add("bottomToTop"); } else { parts.add("topToBottom"); } return Strings.join(parts).with(", "); }
/** * Joins the given {@code Object}s using a given delimiter. The following example illustrates proper usage of this * method: * <pre><code class='java'> Strings.join(new ArrayList("a", "b", "c")).with("|");</code></pre> * * which will result in the {@code String} <code>"a|b|c"</code>. * * @param toStringable the {@code Object}s to join. * @return an intermediate object that takes a given delimiter and knows how to join the given {@code Object}s. * @see StringsToJoin#with(String) */ public static StringsToJoin join(Iterable<?> toStringable) { String[] strings = Streams.stream(toStringable).map(String::valueOf).toArray(String[]::new); return new StringsToJoin(strings); }
/** * Joins the given {@code Object}s using a given delimiter. The following example illustrates proper usage of this * method: * * <pre><code class='java'> * Strings.join(new ArrayList("a", "b", "c")).with("|") * </code></pre> * * which will result in the {@code String} <code>"a|b|c"</code>. * * @param toStringable the {@code Object}s to join. * @return an intermediate object that takes a given delimiter and knows how to join the given {@code Object}s. * @see StringsToJoin#with(String) */ public static StringsToJoin join(Iterable<?> toStringable) { List<String> strings = newArrayList(); for (Object o : toStringable) { strings.add(String.valueOf(o)); } return new StringsToJoin(strings.toArray(new String[strings.size()])); }
@Override public String next() { switch (state) { case FULL_NAME: state = State.WITHOUT_COUNTRY; return join(PREFIX, osFamily, language, country).with(DELIMETER); case WITHOUT_COUNTRY: state = State.LANGUAGE_ONLY; return join(PREFIX, osFamily, language).with(DELIMETER); case LANGUAGE_ONLY: state = State.END; return join(PREFIX, language).with(DELIMETER); default: throw new NoSuchElementException("There are no more names to generate"); } }
/** * Joins the given {@code String}s using a given delimiter. The following example illustrates proper usage of this * method: * * <pre><code class='java'> * Strings.join("a", "b", "c").with("|") * </code></pre> * * which will result in the {@code String} <code>"a|b|c"</code>. * * @param strings the {@code String}s to join. * @return an intermediate object that takes a given delimiter and knows how to join the given {@code String}s. * @see StringsToJoin#with(String) */ public static StringsToJoin join(String... strings) { return new StringsToJoin(strings); }
private static String directionToString(@GridLayoutAnimationControllerDirection int direction) { List<String> parts = new ArrayList<>(); int horizontal = direction & DIRECTION_HORIZONTAL_MASK; int vertical = direction & DIRECTION_VERTICAL_MASK; if ((horizontal & DIRECTION_RIGHT_TO_LEFT) != 0) { parts.add("rightToLeft"); } else { parts.add("leftToRight"); } if ((vertical & DIRECTION_BOTTOM_TO_TOP) != 0) { parts.add("bottomToTop"); } else { parts.add("topToBottom"); } return Strings.join(parts).with(", "); }
private String imageFileName(String testClass, String testMethod) { return join(testClass, testMethod, PNG).with("."); } }
static String screenshotFileNameFrom(ITestResult result) { String[] parts = namePartsFrom(result); return join(parts).with("."); }
private String imageFileName(String testClass, String testMethod) { return join(testClass, testMethod, PNG).with("."); } }
/** * Creates a new {@link JMenuItemMatcher}. * * @param path the path of the menu to match. */ public JMenuItemMatcher(@Nonnull String... path) { this.label = join(path).with(SEPARATOR); }
protected <T> T getObjects(TypeReference<T> typeReference, String path, String queryParamName, String... queryParams) throws IOException { String urlString = "http://localhost:" + port + "/test" + path; if (queryParams.length > 0) { urlString += "?" + queryParamName + "=" + Strings.join(queryParams).with("&" + queryParamName + "="); } URL url = new URL(urlString); return reader.forType(typeReference).readValue(url.openStream()); } }
/** * Specifies the delimiter to use to join {@code String}s. * * @param delimiter the delimiter to use. * @return the {@code String}s joined using the given delimiter. */ public String with(String delimiter) { return with(delimiter, null); }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }
private void assertDescriptorsNotPresentInFile(File logFile) { try { List<String> contents = Files.readAllLines(logFile.toPath()); String result = Strings.join(contents).with("\n"); assertThat(result).doesNotContain(DESCRIPTOR_1.getLockIdAsString()); assertThat(result).doesNotContain(DESCRIPTOR_2.getLockIdAsString()); } catch (IOException e) { throw new RuntimeException(e); } }
private static String describeDifference(Difference difference, Representation representation) { String actualFieldValue = representation.toStringOf(difference.getActual()); String otherFieldValue = representation.toStringOf(difference.getOther()); boolean sameRepresentation = Objects.areEqual(actualFieldValue, otherFieldValue); String actualFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getActual()) : actualFieldValue; String otherFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getOther()) : otherFieldValue; String additionalInfo = difference.getDescription() .map(desc -> format("%n- reason : %s", escapePercent(desc))) .orElse(""); return format("%nPath to difference: <%s>%n" + "- actual : <%s>%n" + "- expected: <%s>" + additionalInfo, join(difference.getPath()).with("."), escapePercent(actualFieldValueRepresentation), escapePercent(otherFieldValueRepresentation)); }
public static ErrorMessageFactory shouldBeEqualByComparingFieldByFieldRecursive(Object actual, Object other, List<Difference> differences, Representation representation) { List<String> descriptionOfDifferences = differences.stream() .map(difference -> describeDifference(difference, representation)) .collect(toList()); return new ShouldBeEqualByComparingFieldByFieldRecursively("%n" + "Expecting:%n" + " <%s>%n" + "to be equal to:%n" + " <%s>%n" + "when recursively comparing field by field, but found the following difference(s):%n" + join(descriptionOfDifferences).with(format("%n")), actual, other); }
/** * Joins the given {@code String}s using a given delimiter. The following example illustrates proper usage of this * method: * <pre><code class='java'> Strings.join("a", "b", "c").with("|");</code></pre> * * which will result in the {@code String} <code>"a|b|c"</code>. * * @param strings the {@code String}s to join. * @return an intermediate object that takes a given delimiter and knows how to join the given {@code String}s. * @see StringsToJoin#with(String) */ public static StringsToJoin join(String... strings) { return new StringsToJoin(strings); }
public static String extractedDescriptionOf(String... itemsDescription) { return format("Extracted: %s", Strings.join(itemsDescription).with(", ")); }
public String getConcatenatedPath() { return join(path).with("."); } }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }