List of usage examples for com.google.common.collect Iterables all
public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:com.eucalyptus.reporting.upgrade.UpgradeUtils.java
static Function<EntityManager, Boolean> dropTables(final List<String> dropTables) { return new Function<EntityManager, Boolean>() { @Override/*from w ww. j a v a 2s .c o m*/ public Boolean apply(final EntityManager entityManager) { return Iterables.all(dropTables, new Predicate<String>() { @Override public boolean apply(final String table) { entityManager.createNativeQuery("drop table if exists " + table).executeUpdate(); return true; } }); } }; }
From source file:gobblin.util.PublisherUtils.java
/** * Given a {@link Multimap} of {@link Extract}s to {@link WorkUnitState}s, filter out any {@link Extract}s where all * of the corresponding {@link WorkUnitState}s do not meet the given {@link Predicate}. *//*from ww w .j a v a2 s . c om*/ public static Multimap<Extract, WorkUnitState> getExtractsForPredicate( Multimap<Extract, WorkUnitState> extractToWorkUnitStateMap, Predicate<WorkUnitState> predicate) { Multimap<Extract, WorkUnitState> successfulExtracts = ArrayListMultimap.create(); for (Map.Entry<Extract, Collection<WorkUnitState>> entry : extractToWorkUnitStateMap.asMap().entrySet()) { if (Iterables.all(entry.getValue(), predicate)) { successfulExtracts.putAll(entry.getKey(), entry.getValue()); } } return successfulExtracts; }
From source file:com.facebook.buck.jvm.java.autodeps.JavaLibrarySymbolsFinder.java
JavaLibrarySymbolsFinder(ImmutableSortedSet<SourcePath> srcs, JavaFileParser javaFileParser, boolean shouldRecordRequiredSymbols) { // Avoid all the construction in the common case where all srcs are instances of PathSourcePath. this.srcs = Iterables.all(srcs, PathSourcePath.class::isInstance) ? srcs : srcs.stream().filter(PathSourcePath.class::isInstance) .collect(MoreCollectors.toImmutableSortedSet(Ordering.natural())); this.javaFileParser = javaFileParser; this.shouldRecordRequiredSymbols = shouldRecordRequiredSymbols; }
From source file:org.elasticlib.common.json.schema.ListSchema.java
ListSchema(String title, List<Value> list) { super(title, ValueType.ARRAY, false); final List<Schema> tmp = transform(list, SCHEMA_BUILDER); if (!tmp.isEmpty() && Iterables.all(tmp, schema -> schema.equals(tmp.get(0)))) { items = singletonList(tmp.get(0)); } else {/*from ww w . j ava2 s. com*/ items = unmodifiableList(tmp); } }
From source file:org.eclipse.xtext.ui.editor.outline.impl.OutlineFilterAndSorter.java
public IOutlineNode[] filterAndSort(Iterable<IOutlineNode> nodes) { final Iterable<IFilter> enabledFilters = getEnabledFilters(); Iterable<IOutlineNode> filteredNodes = null; if (Iterables.isEmpty(enabledFilters)) { filteredNodes = nodes;// w w w. j a v a2 s . c om } else { filteredNodes = Iterables.filter(nodes, new Predicate<IOutlineNode>() { @Override public boolean apply(final IOutlineNode node) { return Iterables.all(enabledFilters, new Predicate<IFilter>() { @Override public boolean apply(IFilter filter) { return filter.apply(node); } }); } }); } IOutlineNode[] nodesAsArray = Iterables.toArray(filteredNodes, IOutlineNode.class); if (comparator != null && isSortingEnabled()) Arrays.sort(nodesAsArray, comparator); return nodesAsArray; }
From source file:org.apache.abdera2.common.selector.AbstractSelector.java
public boolean none(Iterable<X> items) { if (items == null) return false; return Iterables.all(items, this.negate()); }
From source file:brooklyn.location.affinity.EntityTypeAntiAffinityRule.java
@Override public boolean apply(@Nullable Location input) { Collection<Entity> all = getManagementContext().getEntityManager().getEntities(); return Iterables.all(Iterables.filter(all, entityType), Predicates.not(EntityPredicates.withLocation(input))); }
From source file:com.palantir.common.collect.IterableUtils.java
public static <T> List<List<T>> partitionByHash(List<T> items, int buckets, Function<? super T, Long> f) { Preconditions.checkArgument(Iterables.all(items, Predicates.notNull())); Preconditions.checkArgument(buckets > 0); Preconditions.checkNotNull(f);/*from w w w. j a v a 2 s . c o m*/ ArrayList<List<T>> ret = Lists.newArrayList(); for (int i = 0; i < buckets; i++) { ret.add(Lists.<T>newArrayList()); } for (T item : items) { long hash = f.apply(item); int h = (int) (hash ^ (hash >>> 32)); int i = MathUtils.mod(h, buckets); ret.get(i).add(item); } assert assertCorrectlyPartitioned(items, ret); return ret; }
From source file:com.facebook.buck.apple.AppleAssetCatalog.java
AppleAssetCatalog(Supplier<Collection<Path>> inputPathsSupplier, AppleAssetCatalogDescription.Arg args) { Preconditions.checkArgument(Iterables.all(args.dirs, new Predicate<Path>() { @Override/*from w w w. ja v a 2 s . c o m*/ public boolean apply(@Nullable Path input) { return input.toString().endsWith(".xcassets"); } })); this.inputPathsSupplier = Preconditions.checkNotNull(inputPathsSupplier); this.dirs = ImmutableSet.copyOf(args.dirs); this.copyToBundles = args.copyToBundles.or(Boolean.FALSE); }
From source file:com.google.devtools.build.lib.skyframe.TransitiveTargetCycleReporter.java
@Override protected boolean canReportCycle(SkyKey topLevelKey, CycleInfo cycleInfo) { return Iterables.all( Iterables.concat(ImmutableList.of(topLevelKey), cycleInfo.getPathToCycle(), cycleInfo.getCycle()), IS_TRANSITIVE_TARGET_SKY_KEY); }