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

The following examples show how to use java.util.Collections#unmodifiableCollection() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: javaide   File: Paths.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 2
Source Project: Javacord   File: RoleImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<User> getUsers() {
    if (isEveryoneRole()) {
        return getServer().getMembers();
    }

    userHashSetLock.readLock().lock();
    try {
        return Collections.unmodifiableCollection(new ArrayList<>(users));
    } finally {
        userHashSetLock.readLock().unlock();
    }
}
 
Example 3
Source Project: linq   File: WhereTest.java    License: Apache License 2.0 5 votes vote down vote up
@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));
    }
}
 
Example 4
/**
 * 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
@Override
public Collection<ServerFeature> getOldServerFeatures() {
    return Collections.unmodifiableCollection(new HashSet<>(oldServerFeature));
}
 
Example 6
public Collection<VerificationError> getErrors() {
    return Collections.unmodifiableCollection(errors);
}
 
Example 7
public Collection<String> getFieldValues() {
    if (fieldValues != null) {
        return Collections.unmodifiableCollection(fieldValues);
    }
    return Collections.emptySet();
}
 
Example 8
Source Project: onos   File: SimpleLinkStore.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<Link> getLinks() {
    return Collections.unmodifiableCollection(links.values());
}
 
Example 9
public Collection<ParameterCondition> getConditions() {
	return Collections.unmodifiableCollection(conditions);
}
 
Example 10
public Collection<String> getGroups() {
	return Collections.unmodifiableCollection(_customItemsByGroup.keySet());
}
 
Example 11
@Override
@Transactional
public Collection<Connection> getAll(Collection<String> identifiers) throws GuacamoleException {
    Collection<ModeledConnection> objects = connectionService.retrieveObjects(getCurrentUser(), identifiers);
    return Collections.<Connection>unmodifiableCollection(objects);
}
 
Example 12
Source Project: dubbox   File: JdkCompiler.java    License: Apache License 2.0 4 votes vote down vote up
Collection<JavaFileObject> files() {
    return Collections.unmodifiableCollection(classes.values());
}
 
Example 13
Source Project: mybatis   File: TypeHandlerRegistry.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @since 3.2.2
 */
public Collection<TypeHandler<?>> getTypeHandlers() {
  return Collections.unmodifiableCollection(ALL_TYPE_HANDLERS_MAP.values());
}
 
Example 14
Source Project: flink   File: TestingSchedulingTopology.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<TestingSchedulingExecutionVertex> getVertices() {
	return Collections.unmodifiableCollection(schedulingExecutionVertices.values());
}
 
Example 15
Source Project: onos   File: Highlights.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the collection of host highlights.
 *
 * @return host highlights
 */
public Collection<HostHighlight> hosts() {
    return Collections.unmodifiableCollection(hosts.values());
}
 
Example 16
/**
 * Returns an instance of a new builder.
 *
 * @param scopes OAuth scopes
 * @since 1.15
 */
public Builder(Collection<String> scopes) {
  this.scopes = Collections.unmodifiableCollection(scopes);
}
 
Example 17
/**
 * 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);
}
 
Example 18
Source Project: CQL   File: Sketch.java    License: GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * 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());
}
 
Example 19
/**
 * Returns an unmodifiable Collection containing the pages.
 *
 * @return the pages of this activity
 */
public final Collection<Fragment> getPages() {
	return Collections.unmodifiableCollection(pages);
}
 
Example 20
/**
 * 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);
}