Example usage for java.util Collections unmodifiableNavigableSet

List of usage examples for java.util Collections unmodifiableNavigableSet

Introduction

In this page you can find the example usage for java.util Collections unmodifiableNavigableSet.

Prototype

public static <T> NavigableSet<T> unmodifiableNavigableSet(NavigableSet<T> s) 

Source Link

Document

Returns an unmodifiable view of the specified navigable set.

Usage

From source file:org.diorite.config.impl.ConfigPropertyTemplateImpl.java

@Nullable
@Override/*from w w w.  java 2  s.c  o  m*/
public T get(ConfigPropertyValue<T> propertyValue) {
    T rawValue = propertyValue.getRawValue();
    if (rawValue == null) {
        return null;
    }
    if (this.returnUnmodifiableCollections) {
        if (rawValue instanceof Collection) {
            if (rawValue instanceof Set) {
                if (rawValue instanceof NavigableSet) {
                    return (T) Collections.unmodifiableNavigableSet((NavigableSet<?>) rawValue);
                }
                if (rawValue instanceof SortedSet) {
                    return (T) Collections.unmodifiableSortedSet((SortedSet<?>) rawValue);
                }
                return (T) Collections.unmodifiableSet((Set<?>) rawValue);
            }
            if (rawValue instanceof List) {
                return (T) Collections.unmodifiableList((List<?>) rawValue);
            }
            return (T) Collections.unmodifiableCollection((Collection<?>) rawValue);
        } else if (rawValue instanceof Map) {
            if (rawValue instanceof NavigableMap) {
                return (T) Collections.unmodifiableNavigableMap((NavigableMap<?, ?>) rawValue);
            }
            if (rawValue instanceof SortedMap) {
                return (T) Collections.unmodifiableSortedMap((SortedMap<?, ?>) rawValue);
            }
            return (T) Collections.unmodifiableMap((Map<?, ?>) rawValue);
        }
    }
    return rawValue;
}