/** * Factory method to create an unmodifiable set. * * @param <E> the element type * @param set the set to decorate, must not be null * @return a new unmodifiable {@link SortedSet} * @throws NullPointerException if set is null * @since 4.0 */ public static <E> SortedSet<E> unmodifiableSortedSet(final SortedSet<E> set) { if (set instanceof Unmodifiable) { return set; } return new UnmodifiableSortedSet<>(set); }