Strings { @Nullable public static String truncate(@Nullable String text, int maxLength) { if (text == null) return null; if (text.length() <= maxLength) return text; return text.substring(0, maxLength); }  static byte[] bytes(String text); static String format(String pattern, Object... params); static int compare(@Nullable String text1, @Nullable String text2); static boolean isBlank(@Nullable String text); static boolean equals(@Nullable String text1, @Nullable String text2); @Nullable static String truncate(@Nullable String text, int maxLength); @Nullable static String strip(@Nullable String text); static boolean startsWith(String text, char prefix); static String[] split(String text, char delimiter);  }
@Test void truncate() { assertThat(Strings.truncate(null, 10)).isNull(); assertThat(Strings.truncate("value", 10)).isEqualTo("value"); assertThat(Strings.truncate("123456789012345", 10)).isEqualTo("1234567890"); }