List of usage examples for com.google.common.collect Iterables filter
@GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType)
From source file:org.eclipse.sirius.business.internal.session.RepresentationNameListener.java
/** * {@inheritDoc}//from w w w. j av a 2s .co m */ @Override public void resourceSetChanged(ResourceSetChangeEvent event) { for (Notification notif : Iterables.filter(event.getNotifications(), Notification.class)) { if (isRepresentationNameChange(notif)) { Option<Session> session = getSessionFromRepresentation((DRepresentation) notif.getNotifier()); if (session.some()) { SessionManager.INSTANCE.notifyRepresentationRenamed(session.get()); } } } }
From source file:org.gradle.api.internal.classloading.MemoryLeakPrevention.java
public MemoryLeakPrevention(String name, ClassLoader leakingLoader, final ClassPath classPath, Strategy... strategies) {/* w w w . java 2 s .c o m*/ this.name = name; this.strategies = Sets.newHashSet(Iterables.filter(Arrays.asList(strategies), new Predicate<Strategy>() { @Override public boolean apply(Strategy input) { return input.appliesTo(classPath); } })); this.leakingLoader = leakingLoader; }
From source file:org.eclipse.xtext.example.domainmodel.validation.DomainmodelJavaValidator.java
@Check void checkEntityUniquenessWithinPackage(PackageDeclaration declaration) { EList<AbstractElement> elements = declaration.getElements(); ArrayList<AbstractElement> entities = Lists .newArrayList(Iterables.filter(elements, new Predicate<AbstractElement>() { @Override/*from w w w .j a va 2 s . c o m*/ public boolean apply(AbstractElement input) { return input instanceof Entity; } })); Set<String> names = new HashSet<String>(); for (AbstractElement element : entities) { if (!names.add(((Entity) element).getName())) { error("Duplicate entity with name \"" + ((Entity) element).getName() + "\"", element, DomainmodelPackage.Literals.TYPE__NAME); } } }
From source file:org.jclouds.rest.functions.ReturnEmptyMultimapOnNotFoundOr404.java
public Object apply(Exception from) { Iterable<ResourceNotFoundException> throwables = Iterables.filter(Throwables.getCausalChain(from), ResourceNotFoundException.class); if (Iterables.size(throwables) >= 1) { return ImmutableMultimap.of(); } else if (rto404.apply(from)) { return ImmutableMultimap.of(); }/*from w w w . j a v a2 s. com*/ return Multimap.class.cast(propagateOrNull(from)); }
From source file:org.jclouds.tmrk.enterprisecloud.functions.ReturnEmptyVirtualMachinesOnNotFoundOr404.java
public Object apply(Exception from) { Iterable<ResourceNotFoundException> throwables = Iterables.filter(Throwables.getCausalChain(from), ResourceNotFoundException.class); if (Iterables.size(throwables) >= 1) { return VirtualMachines.builder().build(); } else if (rto404.apply(from)) { return VirtualMachines.builder().build(); }/*from w w w .java2 s .c o m*/ return VirtualMachines.class.cast(propagateOrNull(from)); }
From source file:org.eclipse.qvtd.compiler.internal.scheduler.AbstractSimpleNode.java
@Override public final @NonNull Iterable<SimpleNavigationEdge> getCastEdges() { @SuppressWarnings({ "null", "unchecked" }) @NonNull/* w w w . ja v a2 s . com*/ Iterable<SimpleNavigationEdge> filter = (Iterable<SimpleNavigationEdge>) (Object) Iterables .filter(getOutgoingEdges(), AbstractRegion.IsCastEdgePredicate.INSTANCE); return filter; }
From source file:org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateLineMenuAction.java
/** * {@inheritDoc}// w ww .j a v a2s.co m */ @Override protected List<CreateLineAction> filter(List<AbstractToolAction> createActionsForTable) { return Lists.newArrayList(Iterables.filter(createActionsForTable, CreateLineAction.class)); }
From source file:com.google.gerrit.server.change.AllowedFormats.java
@Inject AllowedFormats(DownloadConfig cfg) {//w w w . jav a 2 s . com Map<String, ArchiveFormat> exts = new HashMap<>(); for (ArchiveFormat format : cfg.getArchiveFormats()) { for (String ext : format.getSuffixes()) { exts.put(ext, format); } exts.put(format.name().toLowerCase(), format); } extensions = ImmutableMap.copyOf(exts); // Zip is not supported because it may be interpreted by a Java plugin as a // valid JAR file, whose code would have access to cookies on the domain. allowed = Sets.immutableEnumSet(Iterables.filter(cfg.getArchiveFormats(), f -> f != ArchiveFormat.ZIP)); }
From source file:com.synflow.ngDesign.ui.internal.navigator.CxLabelDecorator.java
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile) { IFile file = (IFile) element;//from w w w . j av a2 s . c o m if (FILE_EXT_CX.equals(file.getFileExtension())) { Module module = getEObject(file, Module.class); if (module != null) { Iterable<Network> networks = Iterables.filter(module.getEntities(), Network.class); if (!Iterables.isEmpty(networks)) { ImageDescriptor descriptor = CxActivator.imageDescriptorFromPlugin("com.synflow.cx.ui", "icons/overlay_network.png"); decoration.addOverlay(descriptor); } } } } }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.query.ISequenceElementQuery.java
/** * Check the presence of the absolute bounds flag. * /*from w ww.j a v a 2s. c o m*/ * @return true if the element is flagged. */ public boolean hasAbsoluteBoundsFlag() { if (event.getNotationView() != null && event.getNotationView().getElement() instanceof DDiagramElement) { DDiagramElement dde = (DDiagramElement) event.getNotationView().getElement(); return !Iterables.isEmpty(Iterables.filter(dde.getGraphicalFilters(), AbsoluteBoundsFilter.class)); } return false; }