/** * 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 NavigableSet} * @throws NullPointerException if set is null */ public static <E> NavigableSet<E> unmodifiableNavigableSet(final NavigableSet<E> set) { if (set instanceof Unmodifiable) { return set; } return new UnmodifiableNavigableSet<>(set); }