Example usage for com.google.common.collect Iterables filter

List of usage examples for com.google.common.collect Iterables filter

Introduction

In this page you can find the example usage for com.google.common.collect Iterables filter.

Prototype

@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType) 

Source Link

Document

Returns all elements in unfiltered that are of the type desiredType .

Usage

From source file:edu.umd.cs.psl.application.learning.weight.em.LatentObjectiveComputer.java

public LatentObjectiveComputer(Model model, Database rvDB, Database observedDB, ConfigBundle config)
        throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    super(model, rvDB, observedDB, config);

    /* Gathers the CompatibilityKernels */
    for (CompatibilityKernel k : Iterables.filter(model.getKernels(), CompatibilityKernel.class))
        if (k.isWeightMutable())
            kernels.add(k);//from w  w w  .ja va2  s  . c  o m
        else
            immutableKernels.add(k);

    /* Sets up the ground model */
    initGroundModel();
}

From source file:org.eclipse.xtext.scoping.impl.FilteringScope.java

@Override
public Iterable<IEObjectDescription> getAllElements() {
    return Iterables.filter(delegate.getAllElements(), filter);
}

From source file:uk.ac.stfc.isis.ibex.configserver.internal.ComponentFilteredConfiguration.java

/**
 * Takes a collection of IOCs and filters out the ones that are part of a
 * component.//from   w  w  w.j av  a2 s .  c  o  m
 * 
 * @param iocs
 *            The IOCs
 * @return The filtered collection of IOCs
 */
public static Collection<Ioc> filterIocs(Collection<Ioc> iocs) {
    return Lists.newArrayList(Iterables.filter(iocs, new Predicate<Ioc>() {
        @Override
        public boolean apply(Ioc ioc) {
            return !ioc.hasComponent();
        }
    }));
}

From source file:ec.nbdemetra.ui.tsaction.TsViewsTsAction.java

@Override
public void open(Ts ts) {
    for (ITsAble o : Iterables.filter(TopComponent.getRegistry().getOpened(), ITsAble.class)) {
        o.setTs(ts);
    }
}

From source file:org.caleydo.view.entourage.GLEntourageWindow.java

@Override
protected void renderImpl(GLGraphics g, float w, float h) {
    if (w <= 1 || h <= 1) { // just render the SlideInElements
        g.incZ();//  w ww.j  ava2s . c  om
        for (SlideInElement child : Iterables.filter(this, SlideInElement.class))
            child.render(g);
        g.decZ();
    } else
        // render normally
        super.renderImpl(g, w, h);
}

From source file:org.apache.hadoop.hbase.master.cleaner.BaseFileCleanerDelegate.java

@Override
public Iterable<FileStatus> getDeletableFiles(Iterable<FileStatus> files) {
    return Iterables.filter(files, new Predicate<FileStatus>() {
        @Override/*w  w w .  java2s. co m*/
        public boolean apply(FileStatus file) {
            return isFileDeletable(file);
        }
    });
}

From source file:org.eclipse.viatra.query.patternlanguage.emf.util.internal.PatternParserResourceDescriptions.java

@Override
public Iterable<IResourceDescription> getAllResourceDescriptions() {
    return Iterables.filter(super.getAllResourceDescriptions(),
            Predicates.not(rd -> rd.getURI().toString().contains(PatternParser.SYNTHETIC_URI_PREFIX)));
}

From source file:org.gradle.api.internal.artifacts.resolution.DefaultArtifactResolutionQueryResult.java

public <T extends SoftwareComponent<?>> Set<T> getComponents(final Class<T> type) {
    return Sets.newHashSet(Iterables.filter(components, type));
}

From source file:org.eclipse.emf.compare.internal.spec.ConflictSpec.java

/**
 * {@inheritDoc}//from   w w w  . j  a  v a 2  s .c  o  m
 * 
 * @see org.eclipse.emf.compare.impl.ConflictImpl#getLeftDifferences()
 */
@Override
public EList<Diff> getLeftDifferences() {
    final EList<Diff> leftDiffs = new BasicEList<Diff>();
    for (Diff diff : Iterables.filter(getDifferences(), EMFComparePredicates.fromSide(DifferenceSource.LEFT))) {
        leftDiffs.add(diff);
    }
    return leftDiffs;
}

From source file:org.gradle.internal.Actions.java

/**
 * Creates an action that will call each of the given actions in order.
 *
 * @param actions The actions to make a composite of.
 * @param <T> The type of the object that action is for
 * @return The composite action./*from   w  w  w .  j a  v a2  s . c om*/
 */
public static <T> Action<T> composite(Iterable<? extends Action<? super T>> actions) {
    return composite(ImmutableList.copyOf(Iterables.filter(actions, DOES_SOMETHING)));
}