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

The following examples show how to use com.google.common.collect.Iterables#unmodifiableIterable() . 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 File: HostOffers.java    From attic-aurora with 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
Source File: Experiments.java    From alchemy with 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 3
Source File: GuavaCollectionsExamplesUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@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 4
Source File: ModelDriver.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Iterable<Error> getErrors() {
	return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
 
Example 5
Source File: MatchManagerImpl.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Iterable<? extends Audience> getAudiences() {
  return Iterables.unmodifiableIterable(matchById.values());
}
 
Example 6
Source File: SimpleNlriRegistry.java    From bgpcep with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Iterable<NlriSerializer> getSerializers() {
    return Iterables.unmodifiableIterable(this.serializers.values());
}
 
Example 7
Source File: Experiments.java    From alchemy with MIT License 4 votes vote down vote up
/**
 * Finds all experiments
 */
public Iterable<Experiment> find() {
    return Iterables.unmodifiableIterable(
        find(Filter.criteria().build())
    );
}
 
Example 8
Source File: Experiments.java    From alchemy with 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 9
Source File: XtbMessageBundle.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Iterable<JsMessage> getAllMessages() {
  return Iterables.unmodifiableIterable(messages.values());
}
 
Example 10
Source File: TableEditorTH.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Iterable<Editor> getEditors() {
	return Iterables.unmodifiableIterable((Collection) this.aspects);
}
 
Example 11
Source File: GraphImpl.java    From kieker with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<IVertex> getVertices() {
	return Iterables.unmodifiableIterable(this.vertices.values());
}
 
Example 12
Source File: AbstractInput.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Iterable<Error> getErrors() {
	return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
 
Example 13
Source File: CompositeGeneratorException.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public Iterable<Exception> getExceptions() {
	return Iterables.unmodifiableIterable(exceptions);
}
 
Example 14
Source File: SingletonRegistry.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
protected Iterable<Service> getServices() {
  return Iterables.unmodifiableIterable(registry.getServices());
}
 
Example 15
Source File: MaterializationCache.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
Iterable<MaterializationDescriptor> getAll() {
  return Iterables.unmodifiableIterable(cached.get().values());
}
 
Example 16
Source File: BusBreakerVoltageLevel.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public Iterable<Switch> getSwitches() {
    return Iterables.unmodifiableIterable(Iterables.transform(graph.getEdgesObject(), Functions.identity()));
}
 
Example 17
Source File: BusBreakerVoltageLevel.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public Iterable<Bus> getBuses() {
    return Iterables.unmodifiableIterable(Iterables.transform(graph.getVerticesObj(), Functions.identity()));
}
 
Example 18
Source File: AcyclicDepthFirstPostOrderTraversal.java    From buck with Apache License 2.0 3 votes vote down vote up
/**
 * 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
Source File: AcyclicDepthFirstPostOrderTraversalWithDependencyStack.java    From buck with Apache License 2.0 3 votes vote down vote up
/**
 * 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
Source File: Theme.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 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);
}