下面列出了java.util.Collections#unmodifiableCollection ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
Collection<File> otherSearchPath() {
if (otherSearchPath == null) {
lazy();
Path userClassPath = getPathForLocation(CLASS_PATH);
Path sourcePath = getPathForLocation(SOURCE_PATH);
if (sourcePath == null)
otherSearchPath = userClassPath;
else {
otherSearchPath = new Path();
otherSearchPath.addAll(userClassPath);
otherSearchPath.addAll(sourcePath);
}
}
return Collections.unmodifiableCollection(otherSearchPath);
}
@Override
public Collection<User> getUsers() {
if (isEveryoneRole()) {
return getServer().getMembers();
}
userHashSetLock.readLock().lock();
try {
return Collections.unmodifiableCollection(new ArrayList<>(users));
} finally {
userHashSetLock.readLock().unlock();
}
}
@Test
void Where_IReadOnlyCollection_ReturnsExpectedValues_True() {
Collection<Integer> source = Collections.unmodifiableCollection(Arrays.asList(1, 2, 3, 4, 5));
Predicate1<Integer> truePredicate = (value) -> true;
IEnumerable<Integer> result = Linq.of(source).where(truePredicate);
assertEquals(source.size(), result.count());
for (int i = 0; i < source.size(); i++) {
assertEquals(Linq.of(source).elementAt(i), result.elementAt(i));
}
}
/**
* 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);
}
@Override
public Collection<ServerFeature> getOldServerFeatures() {
return Collections.unmodifiableCollection(new HashSet<>(oldServerFeature));
}
public Collection<VerificationError> getErrors() {
return Collections.unmodifiableCollection(errors);
}
public Collection<String> getFieldValues() {
if (fieldValues != null) {
return Collections.unmodifiableCollection(fieldValues);
}
return Collections.emptySet();
}
@Override
public Iterable<Link> getLinks() {
return Collections.unmodifiableCollection(links.values());
}
public Collection<ParameterCondition> getConditions() {
return Collections.unmodifiableCollection(conditions);
}
public Collection<String> getGroups() {
return Collections.unmodifiableCollection(_customItemsByGroup.keySet());
}
@Override
@Transactional
public Collection<Connection> getAll(Collection<String> identifiers) throws GuacamoleException {
Collection<ModeledConnection> objects = connectionService.retrieveObjects(getCurrentUser(), identifiers);
return Collections.<Connection>unmodifiableCollection(objects);
}
Collection<JavaFileObject> files() {
return Collections.unmodifiableCollection(classes.values());
}
/**
* @since 3.2.2
*/
public Collection<TypeHandler<?>> getTypeHandlers() {
return Collections.unmodifiableCollection(ALL_TYPE_HANDLERS_MAP.values());
}
@Override
public Iterable<TestingSchedulingExecutionVertex> getVertices() {
return Collections.unmodifiableCollection(schedulingExecutionVertices.values());
}
/**
* Returns the collection of host highlights.
*
* @return host highlights
*/
public Collection<HostHighlight> hosts() {
return Collections.unmodifiableCollection(hosts.values());
}
/**
* Returns an instance of a new builder.
*
* @param scopes OAuth scopes
* @since 1.15
*/
public Builder(Collection<String> scopes) {
this.scopes = Collections.unmodifiableCollection(scopes);
}
/**
* Gets all failures, if there were any.
*
* The collection will be unmodifiable and immutable; if it is not empty, subsequent invocations of this method
* may all return same collection instance, but only as long as no additional failures are reported. If new
* failures are reported, they and the previous will be in a new collection instance.
* @return an unmodifiable, immutable collection of failures; will be empty if all validations passed.
*/
public Collection<AISValidationFailure> failures() {
return Collections.unmodifiableCollection(failureList);
}
/**
* Accessor for the set of views on this sketch.
*
* @return Collection of the views on this sketch
*/
@Override
public Collection<ViewNode> getViews() {
return Collections.unmodifiableCollection(_views.values());
}
/**
* Returns an unmodifiable Collection containing the pages.
*
* @return the pages of this activity
*/
public final Collection<Fragment> getPages() {
return Collections.unmodifiableCollection(pages);
}
/**
* Return the option templates for all the valid option supported.
*
* @return a collection of OptionTemplate objects.
*/
public static Collection<OptionTemplate> getValidOptions() {
return Collections.unmodifiableCollection(validOptions);
}