Util { public static <T> String toString( Iterable<T> iterable, String start, String sep, String end) { final StringBuilder buf = new StringBuilder(); buf.append(start); for (Ord<T> ord : Ord.zip(iterable)) { if (ord.i > 0) { buf.append(sep); } buf.append(ord.e); } buf.append(end); return buf.toString(); } private  Util(); static void discard(Object o); static void discard(int i); static boolean discard(boolean b); static void discard(double d); static void swallow(
      Throwable e,
      Logger logger); static boolean equal(
      Object s0,
      Object s1); static boolean equalShallow(
      List<? extends T> list0, List<? extends T> list1); static int hash(
      int i,
      int j); static int hash(
      int h,
      Object o); static int hashArray(
      int h,
      Object[] a); static int hashV(Object... a); static int hashCode(double v); static Set<T> minus(Set<T> set1, Set<T> set2); static double nLogN(double d); static void print(
      PrintWriter pw,
      Object o); static void print(
      PrintWriter pw,
      Object o,
      int indent); static void printJavaString(
      PrintWriter pw,
      String s,
      boolean nullMeansNull); static void println(
      PrintWriter pw,
      Object o); static String toScientificNotation(BigDecimal bd); static String replace(
      String s,
      String find,
      String replace); static URL toURL(File file); static String getFileTimestamp(); static String stripDoubleQuotes(String value); static String toJavaId(
      String s,
      int ordinal); static String toLinux(String s); static List<T> toList(Iterator<T> iter); static boolean isNullOrEmpty(String s); static String commaList(List<T> list); static String sepList(List<T> list, String sep); static Charset getDefaultCharset(); static Error newInternal(); static Error newInternal(String s); static Error newInternal(Throwable e); static Error newInternal(Throwable e, String s); static String getMessages(Throwable t); static String getStackTrace(Throwable t); static void pre(boolean b, String description); static void post(boolean b, String description); static void permAssert(boolean b, String description); static RuntimeException needToImplement(Object o); static T deprecated(T argument, boolean fail); static void loadLibrary(String libName); static boolean contains(
      String[] a,
      int length,
      String s); static String readAllAsString(Reader reader); static void squelchJar(JarFile jar); static void squelchStream(InputStream stream); static void squelchStream(OutputStream stream); static void squelchReader(Reader reader); static void squelchWriter(Writer writer); static void squelchStmt(Statement stmt); static void squelchConnection(Connection connection); static String rtrim(String s); static String rpad(String s, int len); static String toString(
      Iterable<T> iterable, String start, String sep, String end); static String toPosix(TimeZone tz, boolean verbose); static Locale parseLocale(String localeString); static int runApplication(
      String[] cmdarray,
      Logger logger,
      Reader appInput,
      Writer appOutput); static ProcessBuilder newAppProcess(String[] cmdarray); static int runAppProcess(
      ProcessBuilder pb,
      Logger logger,
      Reader appInput,
      Writer appOutput); static List<E> cast(List<? super E> list, Class<E> clazz); static Iterator<E> cast(
      final Iterator<?> iter,
      final Class<E> clazz); static Iterable<E> cast(
      final Iterable<? super E> iterable,
      final Class<E> clazz); static Iterable<E> filter(
      final Iterable<? extends Object> iterable,
      final Class<E> includeFilter); static Collection<E> filter(
      final Collection<?> collection,
      final Class<E> includeFilter); static List<E> filter(
      final List<?> list,
      final Class<E> includeFilter); static Map<String, String> toMap(
      final Properties properties); static Map<K, V> mapOf(K key, V value, Object... keyValues); static Error unexpected(E value); static Map<String, T> enumConstants(
      Class<T> clazz); @SuppressWarnings({"unchecked" }) static synchronized T enumVal(
      Class<T> clazz,
      String name); static List<E> quotientList(
      final List<E> list, final int n, final int k); static T first(T t0, T t1); static Iterable<T> orEmpty(Iterable<T> t0); static E last(List<E> list); static List<E> skipLast(List<E> list); static List<E> skipLast(List<E> list, int n); static List<E> last(List<E> list, int n); static List<E> skip(List<E> list); static List<E> skip(List<E> list, int fromIndex); static List<Integer> range(final int start, final int end); static String toCamelCase(String name); static String camelToUpper(String name); static boolean isDistinct(List<E> list); static int firstDuplicate(List<E> list); static int match2(List<String> strings, String name,
      boolean caseSensitive1); static boolean match(boolean caseSensitive, String name1,
      String name0); static boolean startsWith(List<E> list0, List<E> list1); static final String AWT_WORKAROUND_PROPERTY; static final String LINE_SEPARATOR; static final String FILE_SEPARATOR; static final String FILE_TIMESTAMP_FORMAT; }
@Test public void testPairAdjacents() { List<String> strings = Arrays.asList("a", "b", "c"); List<String> result = new ArrayList<String>(); for (Pair<String, String> pair : Pair.adjacents(strings)) { result.add(pair.toString()); } assertThat(result.toString(), equalTo("[<a, b>, <b, c>]")); assertThat(Pair.adjacents(ImmutableList.of()).iterator().hasNext(), is(false)); assertThat(Pair.adjacents(ImmutableList.of("a")).iterator().hasNext(), is(false)); assertThat(Iterables.size(Pair.adjacents(Collections.nCopies(100, null))), equalTo(99)); }
@Test public void testPairFirstAnd() { List<String> strings = Arrays.asList("a", "b", "c"); List<String> result = new ArrayList<String>(); for (Pair<String, String> pair : Pair.firstAnd(strings)) { result.add(pair.toString()); } assertThat(result.toString(), equalTo("[<a, b>, <a, c>]")); assertThat(Pair.firstAnd(ImmutableList.of()).iterator().hasNext(), is(false)); assertThat(Pair.firstAnd(ImmutableList.of("a")).iterator().hasNext(), is(false)); assertThat(Iterables.size(Pair.firstAnd(Collections.nCopies(100, null))), equalTo(99)); }
@Test public void testSpaceString() { assertThat(Spaces.sequence(0).toString(), equalTo("")); assertThat(Spaces.sequence(1).toString(), equalTo(" ")); assertThat(Spaces.sequence(9).toString(), equalTo(" ")); assertThat(Spaces.sequence(5).toString(), equalTo(" ")); String s = new StringBuilder().append("xx").append(Spaces.MAX, 0, 100) .toString(); assertThat(s.length(), equalTo(102)); assertThat(Spaces.sequence(1000000000).length(), equalTo(1000000000)); final StringWriter sw = new StringWriter(); Spaces.append(sw, 4); assertThat(sw.toString(), equalTo(" ")); final StringBuilder buf = new StringBuilder(); Spaces.append(buf, 4); assertThat(buf.toString(), equalTo(" ")); assertThat(Spaces.padLeft("xy", 5), equalTo(" xy")); assertThat(Spaces.padLeft("abcde", 5), equalTo("abcde")); assertThat(Spaces.padLeft("abcdef", 5), equalTo("abcdef")); assertThat(Spaces.padRight("xy", 5), equalTo("xy ")); assertThat(Spaces.padRight("abcde", 5), equalTo("abcde")); assertThat(Spaces.padRight("abcdef", 5), equalTo("abcdef")); }