### Question:
LegacyTaglibFunctions { public static int length(@Nullable final Object obj) { if (obj == null) { return 0; } if (obj instanceof String) { return ((String) obj).length(); } if (obj instanceof Collection) { return ((Collection) obj).size(); } if (obj instanceof Map) { return ((Map) obj).size(); } int count = 0; if (obj instanceof Iterator) { final Iterator iter = (Iterator)obj; count = 0; while (iter.hasNext()) { count++; iter.next(); } return count; } if (obj instanceof Enumeration) { final Enumeration inputEnum = (Enumeration)obj; count = 0; while (inputEnum.hasMoreElements()) { count++; inputEnum.nextElement(); } return count; } try { count = Array.getLength(obj); return count; } catch (final IllegalArgumentException ex) { } throw new IllegalStateException("Don't know how to iterate over supplied \"items\" in &lt;forEach&gt;"); }  static String toUpperCase(@Nullable final String input); static String toLowerCase(@Nullable final String input); static int indexOf(@Nullable String input, @Nullable String substring); static boolean contains(@Nullable final String input, @Nullable final String substring); static boolean containsIgnoreCase(@Nullable String input, @Nullable String substring); static boolean startsWith(@Nullable String input, @Nullable String substring); static boolean endsWith(@Nullable String input, @Nullable String substring); static String substring(@Nullable String input, int beginIndex, int endIndex); static String substringAfter(@Nullable String input, @Nullable String substring); static String substringBefore(@Nullable String input, @Nullable String substring); static String trim(@Nullable final String input); static String replace(
            @Nullable String input,
            @Nullable String substringBefore,
            final String substringAfter); static String[] split(
            @Nullable String input,
            @Nullable String delimiters); static int length(@Nullable final Object obj); static String join(@Nullable final String[] array, @Nullable String separator);  }### Answer:
@Test public void testLength() { assertThat(length(null)).isEqualTo(0); assertThat(length("")).isEqualTo(0); assertThat(length("foo")).isEqualTo(3); assertThat(length(emptyList())).isEqualTo(0); assertThat(length(ImmutableList.of(1, 2, 3))).isEqualTo(3); assertThat(length(emptySet())).isEqualTo(0); assertThat(length(ImmutableSet.of(1, 2, 3))).isEqualTo(3); assertThat(length(emptyMap())).isEqualTo(0); assertThat(length(ImmutableMap.of(1, 2))).isEqualTo(1); assertThat(length(new String[0])).isEqualTo(0); assertThat(length(new String[3])).isEqualTo(3); }