Return empty sorted set

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 map when having to deal with other collection types.

Java 8

@Test
public void return_empty_sorted_set_java8 () {

    Set<String> emptySortedSet = Collections.emptySortedSet();

    assertTrue(emptySortedSet.isEmpty());
}

Google Guava

@Test
public void return_empty_sorted_set_guava () {

    Set<String> emptySortedSet = ImmutableSortedSet.of();

    assertTrue(emptySortedSet.isEmpty());
}

Apache Commons

@Test
public void return_empty_sorted_set_apache_commons () {

    @SuppressWarnings("unchecked")
    Set<String> emptySortedSet = SetUtils.EMPTY_SORTED_SET;

    assertTrue(emptySortedSet.isEmpty());

}