/** * 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) { 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()])); }
/** * 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); }
/** * 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); }
/** * 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); }