Java Code Examples for java.util.Collections#unmodifiableSortedSet()

The following examples show how to use java.util.Collections#unmodifiableSortedSet() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: sis   File: MetadataSource.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
private static <E> Collection<?> specialize(Collection<?> collection, final Class<?> returnType, final Class<E> elementType) {
    if (!returnType.isAssignableFrom(Set.class)) {
        return collection;
    }
    final Set<E> enumeration;
    if (CodeList.class.isAssignableFrom(elementType)) {
        enumeration = new CodeListSet<>((Class) elementType);
    } else if (Enum.class.isAssignableFrom(elementType)) {
        enumeration = EnumSet.noneOf((Class) elementType);
    } else {
        /*
         * If 'returnType' is Collection.class, do not copy into a Set since a List
         * is probably good enough. Copy only if a Set is explicitly requested.
         */
        if (Set.class.isAssignableFrom(returnType)) {
            if (SortedSet.class.isAssignableFrom(returnType)) {
                if (collection.isEmpty()) {
                    collection = Collections.emptySortedSet();
                } else {
                    collection = Collections.unmodifiableSortedSet(new TreeSet<>(collection));
                }
            } else {
                switch (collection.size()) {
                    case 0:  collection = Collections.emptySet(); break;
                    case 1:  collection = Collections.singleton(CollectionsExt.first(collection)); break;
                    default: collection = Collections.unmodifiableSet(new LinkedHashSet<>(collection)); break;
                }
            }
        }
        return collection;
    }
    for (final Object e : collection) {
        enumeration.add(elementType.cast(e));
    }
    return Collections.unmodifiableSet(enumeration);
}
 
Example 2
@Override
SortedSet<V> createUnmodifiableEmptyCollection() {
  Comparator<? super V> comparator = valueComparator();
  if (comparator == null) {
    return Collections.unmodifiableSortedSet(createCollection());
  } else {
    return ImmutableSortedSet.emptySet(valueComparator());
  }
}
 
Example 3
@Override
public Iterator<String> iterator() {
	final Map<String, int[]> map = getIdMap();
	Set<String> set;
	synchronized (map) {
		set = Collections.unmodifiableSortedSet((SortedSet<String>) map.keySet());
	}
	return set.iterator();
}
 
Example 4
@Override
public SortedSet<V> get(K key) {
  return Collections.unmodifiableSortedSet(delegate().get(key));
}
 
Example 5
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 6
Source Project: codebuff   File: Sets.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected SortedSet<E> delegate() {
  return Collections.unmodifiableSortedSet(delegate);
}
 
Example 7
/**
 * @return Sorted observation types set
 */
public SortedSet<String> getObservationTypes() {
    return Collections.unmodifiableSortedSet(observationTypes);
}
 
Example 8
public Set<NbModuleProject> getSubModules() {
    return Collections.unmodifiableSortedSet(subModules);
}
 
Example 9
public SortedSet<WeaponProf> getSortedWeaponProfs()
{
	return Collections.unmodifiableSortedSet(new TreeSet<>(weaponProfFacet.getSet(id)));
}
 
Example 10
Source Project: codebuff   File: Tables.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public SortedSet<R> rowKeySet() {
  return Collections.unmodifiableSortedSet(delegate().rowKeySet());
}
 
Example 11
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 12
/**
 * @return Sorted featureOfInterest list
 */
public SortedSet<String> getFeatureOfInterest() {
    return Collections.unmodifiableSortedSet(featureOfInterest);
}
 
Example 13
protected SortedSet<String> getAnotherObject() {
    SortedSet<String> set = new TreeSet<String>();
    return Collections.unmodifiableSortedSet(set);
}
 
Example 14
public SortedSet<String> getFeatureOfInterestTypes() {
    return Collections.unmodifiableSortedSet(featureOfInterestTypes);
}
 
Example 15
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 16
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 17
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 18
Source Project: arctic-sea   File: OwsHttp.java    License: Apache License 2.0 4 votes vote down vote up
public SortedSet<OwsRequestMethod> getRequestMethods() {
    return Collections.unmodifiableSortedSet(requestMethods);
}
 
Example 19
public SortedSet<WeaponProf> getSortedWeaponProfs()
{
	return Collections.unmodifiableSortedSet(new TreeSet<>(weaponProfFacet.getSet(id)));
}
 
Example 20
/**
 * Returns an unmodifiable view of the specified sorted {@code set}.
 * 
 * @param set
 *            the sorted set for which an unmodifiable view is to be returned. May not be <code>null</code>.
 * @return an unmodifiable view of the specified sorted set.
 * @see Collections#unmodifiableSortedSet(SortedSet)
 */
@Inline(value="$2.$3unmodifiableSortedSet($1)", imported=Collections.class)
public static <T> SortedSet<T> unmodifiableView(SortedSet<T> set) {
	return Collections.unmodifiableSortedSet(set);
}