下面列出了com.google.common.collect.Iterables#unmodifiableIterable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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))));
}
@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();
}
}
/**
* 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
)
);
}
@Override
public Iterable<? extends Audience> getAudiences() {
return Iterables.unmodifiableIterable(matchById.values());
}
@Override
public Iterable<Bus> getBuses() {
return Iterables.unmodifiableIterable(Iterables.transform(graph.getVerticesObj(), Functions.identity()));
}
@Override
public Iterable<Switch> getSwitches() {
return Iterables.unmodifiableIterable(Iterables.transform(graph.getEdgesObject(), Functions.identity()));
}
Iterable<MaterializationDescriptor> getAll() {
return Iterables.unmodifiableIterable(cached.get().values());
}
protected Iterable<Service> getServices() {
return Iterables.unmodifiableIterable(registry.getServices());
}
public Iterable<Exception> getExceptions() {
return Iterables.unmodifiableIterable(exceptions);
}
@Override
public Iterable<Error> getErrors() {
return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
@Override
public Iterable<IVertex> getVertices() {
return Iterables.unmodifiableIterable(this.vertices.values());
}
@Override
public Iterable<Editor> getEditors() {
return Iterables.unmodifiableIterable((Collection) this.aspects);
}
@Override
public Iterable<JsMessage> getAllMessages() {
return Iterables.unmodifiableIterable(messages.values());
}
/**
* Returns all active experiments
*/
public Iterable<Experiment> getActiveExperiments() {
strategy.onCacheRead(context);
return Iterables.unmodifiableIterable(cache.getActiveExperiments().values());
}
/**
* Finds all experiments
*/
public Iterable<Experiment> find() {
return Iterables.unmodifiableIterable(
find(Filter.criteria().build())
);
}
@Override
public Iterable<NlriSerializer> getSerializers() {
return Iterables.unmodifiableIterable(this.serializers.values());
}
@Override
public Iterable<Error> getErrors() {
return this.errors == null ? Collections.<Error> emptyList() : Iterables.unmodifiableIterable(this.errors);
}
/**
* 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());
}
/**
* 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());
}
/**
* 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);
}