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:de.cosmocode.palava.media.expire.AssetExpirationService.java
private void checkUnexpiring() { final List<AssetBase> assets = service.list(AssetBase.UNEXPIRING); assert Iterables.all(assets, AssetBase.IS_UNEXPIRING) : "Expected all assets to be unexpiring"; LOG.info("Found {} unexpiring assets", assets.size()); for (AssetBase asset : assets) { unexpiredEvent.eventAssetUnexpired(asset); }// w w w. j av a 2 s . c o m }
From source file:com.viadeo.kasper.core.id.DefaultIDTransformer.java
@Override public Map<ID, ID> to(final Format format, final ID firstId, final ID... restIds) { checkNotNull(format);/* w w w. jav a2s .c o m*/ List<ID> ids = Lists.asList(firstId, restIds); checkArgument(Iterables.all(ids, Predicates.notNull()), "Each specified ids must be not null"); return doConvertAll(format, ids); }
From source file:org.jclouds.location.suppliers.all.ZoneToRegionToProviderOrJustProvider.java
@Override public Set<? extends Location> get() { Set<? extends Location> regionsOrJustProvider = regionToProviderOrJustProvider.get(); Set<String> zoneIds = zoneIdsSupplier.get(); if (zoneIds.size() == 0) return regionsOrJustProvider; Map<String, Location> zoneIdToParent = setParentOfZoneToRegionOrProvider(zoneIds, regionsOrJustProvider); Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get(); Builder<Location> locations = ImmutableSet.builder(); if (!Iterables.all(regionsOrJustProvider, LocationPredicates.isProvider())) locations.addAll(regionsOrJustProvider); for (Map.Entry<String, Location> entry : zoneIdToParent.entrySet()) { String zoneId = entry.getKey(); Location parent = entry.getValue(); LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(zoneId).description(zoneId) .parent(parent);//from w w w.j av a 2 s.c om if (isoCodesById.containsKey(zoneId)) builder.iso3166Codes(isoCodesById.get(zoneId).get()); // be cautious.. only inherit iso codes if the parent is a region // regions may be added dynamically, and we prefer to inherit an // empty set of codes from a region, then a provider, whose code // are likely hard-coded. else if (parent.getScope() == LocationScope.REGION) builder.iso3166Codes(parent.getIso3166Codes()); locations.add(builder.build()); } return locations.build(); }
From source file:com.google.devtools.build.lib.skyframe.ConfiguredTargetCycleReporter.java
@Override protected String getAdditionalMessageAboutCycle(EventHandler eventHandler, SkyKey topLevelKey, CycleInfo cycleInfo) {// www . jav a 2s. c o m if (Iterables.all(cycleInfo.getCycle(), IS_TRANSITIVE_TARGET_SKY_KEY)) { // The problem happened strictly in loading, so delegate the explanation to // TransitiveTargetCycleReporter. Iterable<SkyKey> pathAsTargetKeys = Iterables.transform(cycleInfo.getPathToCycle(), new Function<SkyKey, SkyKey>() { @Override public SkyKey apply(SkyKey key) { return asTransitiveTargetKey(key); } }); return targetReporter.getAdditionalMessageAboutCycle(eventHandler, asTransitiveTargetKey(topLevelKey), new CycleInfo(pathAsTargetKeys, cycleInfo.getCycle())); } else { return "\nThis cycle occurred because of a configuration option"; } }
From source file:org.eclipse.sirius.business.internal.movida.ViewpointSelection.java
/** * Sets the whole set of selected viewpoints at once. * /*from ww w . j a v a 2 s. c om*/ * @param selection * the logical URIs of all the viewpoints to put in the * selection. */ public void setSelected(Set<URI> selection) { Preconditions.checkArgument(Iterables.all(selection, isValidViewpointURI), INVALID_VIEWPOINT_URI); logicalViewpoints.clear(); logicalViewpoints.addAll(selection); needsValidation = true; }
From source file:ivorius.ivtoolkit.maze.components.MazeComponents.java
public static <C> boolean allExitsCompatible(final MazeComponent<C> existing, final MazeComponent<C> add, final ConnectionStrategy<C> strategy) { return Iterables.all(add.exits().entrySet(), new Predicate<Map.Entry<MazeRoomConnection, C>>() { @Override/* w w w . ja v a 2s. c o m*/ public boolean apply(@Nullable Map.Entry<MazeRoomConnection, C> input) { return input == null || strategy.connect(input.getKey(), existing.exits().get(input.getKey()), input.getValue()); } }); }
From source file:org.lenskit.data.history.BasicUserHistory.java
/** * {@inheritDoc}//from www . j a v a2s . co m * <p>This implementation filters into a new {@link BasicUserHistory} backed * by an {@link ArrayList}. */ @Override public UserHistory<E> filter(Predicate<? super E> pred) { if (Iterables.all(this, pred)) { return this; } else { List<E> evts = ImmutableList.copyOf(Iterables.filter(this, pred)); return new BasicUserHistory<>(getUserId(), evts); } }
From source file:org.grouplens.lenskit.data.history.BasicUserHistory.java
/** * {@inheritDoc}//w w w . j a v a 2 s. c om * <p>This implementation filters into a new {@link BasicUserHistory} backed * by an {@link ArrayList}. */ @Override public UserHistory<E> filter(Predicate<? super E> pred) { if (Iterables.all(this, pred)) { return this; } else { List<E> evts = ImmutableList.copyOf(Iterables.filter(this, pred)); return new BasicUserHistory<E>(getUserId(), evts); } }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.AbstractCopyPasteLayoutAction.java
/** * {@inheritDoc}/* w w w .j av a 2s .co m*/ * * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#calculateEnabled() */ @Override protected final boolean calculateEnabled() { boolean enable = false; if (representationPart != null && !representationPart.equals(getWorkbenchPart())) { return super.isEnabled(); } Collection<DSemanticDecorator> dSelection = getDSelection(getSelectedObjects()); DDiagram parentDiagram = null; for (DSemanticDecorator dsem : dSelection) { if (dsem instanceof DDiagram) { parentDiagram = (DDiagram) dsem; } else if (dsem instanceof DDiagramElement) { parentDiagram = ((DDiagramElement) dsem).getParentDiagram(); } if (parentDiagram != null) { break; } } if (parentDiagram != null) { Predicate<DSemanticDecorator> allowsPasteLayout = allowsCopyPasteLayout(parentDiagram); if (Iterables.all(dSelection, allowsPasteLayout)) { enable = super.calculateEnabled(); } } return enable; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.layout.AbstractCopyPasteFormatAction.java
/** * {@inheritDoc}/*from w w w . j a va 2 s . co m*/ * * @see org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction#calculateEnabled() */ @Override protected final boolean calculateEnabled() { boolean enable = false; if (representationPart != null && !representationPart.equals(getWorkbenchPart())) { return super.isEnabled(); } Collection<DSemanticDecorator> dSelection = getDSelection(getSelectedObjects()); DDiagram parentDiagram = null; for (DSemanticDecorator dsem : dSelection) { if (dsem instanceof DDiagram) { parentDiagram = (DDiagram) dsem; } else if (dsem instanceof DDiagramElement) { parentDiagram = ((DDiagramElement) dsem).getParentDiagram(); } if (parentDiagram != null) { break; } } if (parentDiagram != null) { Predicate<DSemanticDecorator> allowsPasteFormat = allowsCopyPasteFormat(parentDiagram); if (Iterables.all(dSelection, allowsPasteFormat)) { enable = super.calculateEnabled(); } } return enable; }