Return empty sorted map

Effective java Item 43 states return empty arrays or collections, not nulls. In practice you should return the same immutable empty collection every time you return a collection. There are a few ways to handle the exception to the rule when you encounter methods that should return a collection but instead return null. Check out return empty map, return empty set, return empty enumeration, return empty list iterator, return empty iterator and return empty sorted set when having to deal with other collection types.

Java 8

@Test
public void return_empty_sorted_map_java () {

    Map<String, String> sortedEmptyMap = Collections.emptySortedMap();

    assertTrue(sortedEmptyMap.isEmpty());
}

Google Guava

@Test
public void return_empty_sorted_map_guava () {

    Map<String, String> sortedEmptyMap = ImmutableSortedMap.of();

    assertTrue(sortedEmptyMap.isEmpty());
}

Apache Commons

@Test
public void return_empty_sorted_map_apache_commons () {

    @SuppressWarnings("unchecked")
    Map<String, String> sortedEmptyMap = MapUtils.EMPTY_SORTED_MAP;

    assertTrue(sortedEmptyMap.isEmpty());
}