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

The following are Jave code examples for showing how to use unmodifiableSortedSet() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Visitor   File: InternalUtil.java   View Source Code Vote up 6 votes
/**
 * auto Adaptation List, NavigableSet, SortedSet, Set and Collection.
 * 
 * @param <T>
 *            the element type
 * @param collection
 *            the target collection
 * @return a unmodifiable collection
 */
public static <T> Collection<T> unmodifiable(Collection<T> collection) {

	if (collection instanceof List) {
		return Collections.unmodifiableList((List<? extends T>) collection);
	}
	/*
	 * else if (collection instanceof NavigableSet) {
	 * if(JDKVersion.isJdK18()){ //jdk1.8 return
	 * Collections.unmodifiableNavigableSet((NavigableSet<T>) collection); }
	 * }
	 */
	else if (collection instanceof SortedSet) {
		return Collections.unmodifiableSortedSet((SortedSet<T>) collection);
	} else if (collection instanceof Set) {
		return Collections.unmodifiableSet((Set<? extends T>) collection);
	}
	return Collections.unmodifiableCollection(collection);
}
 
Example 2
Project: googles-monorepo-demo   File: AbstractMapBasedMultimap.java   View Source Code Vote up 5 votes
static <E> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection) {
  if (collection instanceof NavigableSet) {
    return Sets.unmodifiableNavigableSet((NavigableSet<E>) collection);
  } else if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<E>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<E>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<E>) collection);
  } else {
    return Collections.unmodifiableCollection(collection);
  }
}
 
Example 3
Project: s-store   File: Multimaps.java   View Source Code Vote up 5 votes
/**
 * Returns an unmodifiable view of the specified collection, preserving the
 * interface for instances of {@code SortedSet}, {@code Set}, {@code List} and
 * {@code Collection}, in that order of preference.
 *
 * @param collection the collection for which to return an unmodifiable view
 * @return an unmodifiable view of the collection
 */
private static <V> Collection<V> unmodifiableValueCollection(
    Collection<V> collection) {
  if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<V>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<V>) collection);
  }
  return Collections.unmodifiableCollection(collection);
}
 
Example 4
Project: sstore-soft   File: Multimaps.java   View Source Code Vote up 5 votes
/**
 * Returns an unmodifiable view of the specified collection, preserving the
 * interface for instances of {@code SortedSet}, {@code Set}, {@code List} and
 * {@code Collection}, in that order of preference.
 *
 * @param collection the collection for which to return an unmodifiable view
 * @return an unmodifiable view of the collection
 */
private static <V> Collection<V> unmodifiableValueCollection(
    Collection<V> collection) {
  if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<V>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<V>) collection);
  }
  return Collections.unmodifiableCollection(collection);
}
 
Example 5
Project: sstore-soft   File: AbstractSortedSetMultimap.java   View Source Code Vote up 5 votes
@Override
SortedSet<V> createUnmodifiableEmptyCollection() {
  Comparator<? super V> comparator = valueComparator();
  if (comparator == null) {
    return Collections.unmodifiableSortedSet(createCollection());
  } else {
    return ImmutableSortedSet.emptySet(valueComparator());
  }
}
 
Example 6
Project: googles-monorepo-demo   File: Multimaps.java   View Source Code Vote up 5 votes
/**
 * Returns an unmodifiable view of the specified collection, preserving the
 * interface for instances of {@code SortedSet}, {@code Set}, {@code List} and
 * {@code Collection}, in that order of preference.
 *
 * @param collection the collection for which to return an unmodifiable view
 * @return an unmodifiable view of the collection
 */
private static <V> Collection<V> unmodifiableValueCollection(Collection<V> collection) {
  if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<V>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<V>) collection);
  }
  return Collections.unmodifiableCollection(collection);
}
 
Example 7
Project: loom   File: CoraRecord.java   View Source Code Vote up 5 votes
public SortedSet<String> getAuthorsShingles() {
    if (authorsShingles == null) {
        authorsShingles = calculateShingles(authors, authorsShingleLenght);
    }

    return Collections.unmodifiableSortedSet(authorsShingles);
}
 
Example 8
Project: guava-mock   File: Multimaps.java   View Source Code Vote up 5 votes
/**
 * Returns an unmodifiable view of the specified collection, preserving the
 * interface for instances of {@code SortedSet}, {@code Set}, {@code List} and
 * {@code Collection}, in that order of preference.
 *
 * @param collection the collection for which to return an unmodifiable view
 * @return an unmodifiable view of the collection
 */
private static <V> Collection<V> unmodifiableValueCollection(Collection<V> collection) {
  if (collection instanceof SortedSet) {
    return Collections.unmodifiableSortedSet((SortedSet<V>) collection);
  } else if (collection instanceof Set) {
    return Collections.unmodifiableSet((Set<V>) collection);
  } else if (collection instanceof List) {
    return Collections.unmodifiableList((List<V>) collection);
  }
  return Collections.unmodifiableCollection(collection);
}
 
Example 9
Project: openjdk-jdk10   File: TIFFTagSet.java   View Source Code Vote up 5 votes
/**
 * Retrieves an unmodifiable lexicographically increasing set of tag names.
 *
 * <p>The returned object is unmodifiable and contains the tag
 * names of all {@code TIFFTag}s in this {@code TIFFTagSet}
 * sorted into ascending order according to
 * {@link String#compareTo(Object)}.</p>
 *
 * @return All tag names in this set.
 */
public SortedSet<String> getTagNames() {
    Set<String> tagNames = allowedTagsByName.keySet();
    SortedSet<String> sortedTagNames;
    if(tagNames instanceof SortedSet) {
        sortedTagNames = (SortedSet<String>)tagNames;
    } else {
        sortedTagNames = new TreeSet<String>(tagNames);
    }

    return Collections.unmodifiableSortedSet(sortedTagNames);
}
 
Example 10
Project: incubator-netbeans   File: SingleModuleProperties.java   View Source Code Vote up 4 votes
protected void refresh(NbModuleType moduleType,
        SuiteProvider suiteProvider) {
    reloadProperties();
    // reset
    this.suiteProvider = suiteProvider;
    this.moduleType = moduleType;
    universeDependencies = null;
    modCategories = null;
    availablePublicPackages = null;
    dependencyListModel = null;
    friendListModel = null;
    requiredTokensListModel = null;
    wrappedJarsListModel = null;
    wrappedJarsChanged = false;
    projectXMLManager = null;
    if (isSuiteComponent()) {
        if (getSuiteDirectory() != null) {
            ModuleList.refreshModuleListForRoot(getSuiteDirectory());
        }
    } else if (isStandalone()) {
        ModuleList.refreshModuleListForRoot(getProjectDirectoryFile());
    }
    ManifestManager manifestManager = ManifestManager.getInstance(getManifestFile(), false);
    majorReleaseVersion = manifestManager.getReleaseVersion();
    specificationVersion = manifestManager.getSpecificationVersion();
    implementationVersion = manifestManager.getImplementationVersion();
    provTokensString = manifestManager.getProvidedTokensString();
    autoUpdateShowInClient = manifestManager.getAutoUpdateShowInClient();

    String nbDestDirS = getEvaluator().getProperty(ModuleList.NETBEANS_DEST_DIR);
    LOG.log(Level.FINE, "Setting NBPlatform for module. '" + getCodeNameBase() + "' in dir '" + nbDestDirS + "'");
    if (nbDestDirS != null) {
        String harnessDir = getEvaluator().getProperty("harness.dir");
        NbPlatform plaf = NbPlatform.getPlatformByDestDir(getHelper().resolveFile(nbDestDirS), harnessDir != null ? getHelper().resolveFile(harnessDir) : null);
        if (!plaf.isValid()) { // #134492
            NbPlatform def = NbPlatform.getDefaultPlatform();
            if (def != null) {
                LOG.log(Level.FINE, "Platform not found, switching to default ({0})", def.getDestDir());
                plaf = def;
            }
        }
        originalPlatform = activePlatform = plaf;
    }
    activeJavaPlatform = getJavaPlatform();
    javaPlatformChanged = false;
    getPublicPackagesModel().reloadData(loadPublicPackages());
    requiredTokens = Collections.unmodifiableSortedSet(
            new TreeSet<String>(Arrays.asList(manifestManager.getRequiredTokens())));
    bundleInfo = bundleInfoProvider.getLocalizedBundleInfo();
    if (bundleInfo != null) {
        try {
            bundleInfo.reload();
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
    firePropertiesRefreshed();
}
 
Example 11
Project: guava-mock   File: UnmodifiableSortedMultiset.java   View Source Code Vote up 4 votes
@Override
SortedSet<E> createElementSet() {
  return Collections.unmodifiableSortedSet(delegate().elementSet());
}
 
Example 12
Project: googles-monorepo-demo   File: Sets.java   View Source Code Vote up 4 votes
@Override
protected SortedSet<E> delegate() {
  return Collections.unmodifiableSortedSet(delegate);
}
 
Example 13
Project: uflo   File: WorkdayCalendar.java   View Source Code Vote up 4 votes
public SortedSet<Date> getIncludedDates() {
    return Collections.unmodifiableSortedSet(workdays);
}
 
Example 14
Project: googles-monorepo-demo   File: Multimaps.java   View Source Code Vote up 4 votes
@Override
public SortedSet<V> get(K key) {
  return Collections.unmodifiableSortedSet(delegate().get(key));
}
 
Example 15
Project: jdk8u-jdk   File: java_util_Collections_UnmodifiableSortedSet.java   View Source Code Vote up 4 votes
protected SortedSet<String> getObject() {
    SortedSet<String> set = new TreeSet<String>();
    set.add("string");
    return Collections.unmodifiableSortedSet(set);
}
 
Example 16
Project: sonar-packageanalyzer-plugin   File: Package.java   View Source Code Vote up 4 votes
/**
 * @return classes
 */
public SortedSet<Class<E>> getClasses() {
	return Collections.unmodifiableSortedSet(new TreeSet<>(classes.values()));
}
 
Example 17
Project: googles-monorepo-demo   File: UnmodifiableSortedMultiset.java   View Source Code Vote up 4 votes
@Override
SortedSet<E> createElementSet() {
  return Collections.unmodifiableSortedSet(delegate().elementSet());
}
 
Example 18
Project: guava-mock   File: Multimaps.java   View Source Code Vote up 4 votes
@Override
public SortedSet<V> get(K key) {
  return Collections.unmodifiableSortedSet(delegate().get(key));
}
 
Example 19
Project: s-store   File: Multimaps.java   View Source Code Vote up 4 votes
@Override public SortedSet<V> get(K key) {
  return Collections.unmodifiableSortedSet(delegate().get(key));
}
 
Example 20
Project: lams   File: HolidayCalendar.java   View Source Code Vote up 2 votes
/**
 * <p>
 * Returns a <code>SortedSet</code> of Dates representing the excluded
 * days. Only the month, day and year of the returned dates are
 * significant.
 * </p>
 */
public SortedSet<Date> getExcludedDates() {
    return Collections.unmodifiableSortedSet(dates);
}