Java Code Examples for com.google.common.collect.Iterables#unmodifiableIterable()

The following examples show how to use com.google.common.collect.Iterables#unmodifiableIterable() . 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: attic-aurora   File: HostOffers.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a weakly-consistent iterable giving the available offers to a given
 * {@code groupKey}. This iterable can handle concurrent operations on its underlying
 * collection, and may reflect changes that happen after the construction of the iterable.
 * This property is mainly used in {@code launchTask}.
 *
 * @param groupKey The task group to get offers for.
 * @return The offers a given task group can use.
 */
synchronized Iterable<HostOffer> getAllMatching(TaskGroupKey groupKey,
                                                ResourceRequest resourceRequest) {

  return Iterables.unmodifiableIterable(
      FluentIterable.from(offers.getOrdered(groupKey, resourceRequest))
          .filter(o -> !isGloballyBanned(o))
          .filter(o -> !isStaticallyBanned(o, groupKey))
          .filter(HostOffer::hasCpuAndMem)
          .filter(o -> !isVetoed(o, resourceRequest, Optional.of(groupKey))));
}
 
Example 2
@Test(expected = UnsupportedOperationException.class)
public final void givenUnmodifiableViewOverIterable_whenTryingToRemove_thenNotAllowed() {
    final List<Integer> numbers = Lists.newArrayList(1, 2, 3);
    final Iterable<Integer> unmodifiableIterable = Iterables.unmodifiableIterable(numbers);
    final Iterator<Integer> iterator = unmodifiableIterable.iterator();
    if (iterator.hasNext()) {
        iterator.remove();
    }
}
 
Example 3
Source Project: alchemy   File: Experiments.java    License: MIT License 5 votes vote down vote up
/**
 * Finds an experiment given a set of criteria
 */
public Iterable<Experiment> find(Filter filter) {
    return Iterables.unmodifiableIterable(
        new CacheStrategyIterable(
            store.find(filter, new Experiment.BuilderFactory(this)),
            context,
            strategy
        )
    );
}
 
Example 4
@Override
public Iterable<? extends Audience> getAudiences() {
  return Iterables.unmodifiableIterable(matchById.values());
}
 
Example 5
@Override
public Iterable<Bus> getBuses() {
    return Iterables.unmodifiableIterable(Iterables.transform(graph.getVerticesObj(), Functions.identity()));
}
 
Example 6
@Override
public Iterable<Switch> getSwitches() {
    return Iterables.unmodifiableIterable(Iterables.transform(graph.getEdgesObject(), Functions.identity()));
}
 
Example 7
Source Project: dremio-oss   File: MaterializationCache.java    License: Apache License 2.0 4 votes vote down vote up
Iterable<MaterializationDescriptor> getAll() {
  return Iterables.unmodifiableIterable(cached.get().values());
}
 
Example 8
Source Project: dremio-oss   File: SingletonRegistry.java    License: Apache License 2.0 4 votes vote down vote up
protected Iterable<Service> getServices() {
  return Iterables.unmodifiableIterable(registry.getServices());
}
 
Example 9
public Iterable<Exception> getExceptions() {
	return Iterables.unmodifiableIterable(exceptions);
}
 
Example 10
@Override
public Iterable<Error> getErrors() {
	return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
 
Example 11
Source Project: kieker   File: GraphImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<IVertex> getVertices() {
	return Iterables.unmodifiableIterable(this.vertices.values());
}
 
Example 12
@Override
public Iterable<Editor> getEditors() {
	return Iterables.unmodifiableIterable((Collection) this.aspects);
}
 
Example 13
@Override
public Iterable<JsMessage> getAllMessages() {
  return Iterables.unmodifiableIterable(messages.values());
}
 
Example 14
Source Project: alchemy   File: Experiments.java    License: MIT License 4 votes vote down vote up
/**
 * Returns all active experiments
 */
public Iterable<Experiment> getActiveExperiments() {
    strategy.onCacheRead(context);
    return Iterables.unmodifiableIterable(cache.getActiveExperiments().values());
}
 
Example 15
Source Project: alchemy   File: Experiments.java    License: MIT License 4 votes vote down vote up
/**
 * Finds all experiments
 */
public Iterable<Experiment> find() {
    return Iterables.unmodifiableIterable(
        find(Filter.criteria().build())
    );
}
 
Example 16
@Override
public Iterable<NlriSerializer> getSerializers() {
    return Iterables.unmodifiableIterable(this.serializers.values());
}
 
Example 17
@Override
public Iterable<Error> getErrors() {
	return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
 
Example 18
/**
 * Performs a depth-first, post-order traversal over a DAG.
 *
 * @param initialNodes The nodes from which to perform the traversal. Not allowed to contain
 *     {@code null}.
 * @param shouldExploreChildren Whether or not to explore a particular node's children. Used to
 *     support short circuiting in the traversal.
 * @throws CycleException if a cycle is found while performing the traversal.
 */
@SuppressWarnings("PMD.PrematureDeclaration")
public Iterable<T> traverse(
    Iterable<? extends T> initialNodes, Predicate<T> shouldExploreChildren)
    throws CycleException {
  return Iterables.unmodifiableIterable(
      traversal.traverse(initialNodes, shouldExploreChildren).keySet());
}
 
Example 19
/**
 * Performs a depth-first, post-order traversal over a DAG.
 *
 * @param initialNodes The nodes from which to perform the traversal. Not allowed to contain
 *     {@code null}.
 * @param shouldExploreChildren Whether or not to explore a particular node's children. Used to
 *     support short circuiting in the traversal.
 * @throws CycleException if a cycle is found while performing the traversal.
 */
@SuppressWarnings("PMD.PrematureDeclaration")
public Iterable<T> traverse(
    Iterable<? extends T> initialNodes, Predicate<T> shouldExploreChildren)
    throws CycleException {
  return Iterables.unmodifiableIterable(
      traversal.traverse(initialNodes, shouldExploreChildren).keySet());
}
 
Example 20
/**
 * Gets the links of the Theme. the links are wrapped in an unmodifiable Iterable.
 *
 * @return the links
 */
public Iterable<CssLink> getLinks() {
	return Iterables.unmodifiableIterable(this.links);
}