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

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

Introduction

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

Prototype

@SuppressWarnings("unchecked") 
@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> UnmodifiableIterator<T> filter(Iterator<?> unfiltered, Class<T> desiredType) 

Source Link

Document

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

Usage

From source file:qdg.view.EdgeSubMixedGraph.java

@Override
public Iterator<Edge> getUEdgeIterator() {
    return Iterators.filter(g.getUEdgeIterator(), edgeFilterPredicate);
}

From source file:org.eclipse.emf.compare.tests.framework.EMFCompareTestBase.java

/**
 * Returns all proper content of the given resource in the form of a list.
 * //from   w w w .  ja  va 2 s. c o m
 * @param res
 *            The resource which content we need.
 * @return The list of all of the given resource's contained EObjects.
 */
protected static List<EObject> getAllProperContent(Resource res) {
    if (res == null) {
        return Lists.newArrayList();
    }

    final Iterator<Object> properContent = EcoreUtil.getAllProperContents(res, false);
    final Iterator<EObject> filter = Iterators.filter(properContent, EObject.class);
    return Lists.newArrayList(filter);
}

From source file:org.eclipse.sirius.diagram.sequence.business.internal.query.TSequenceDiagramQuery.java

/**
 * return any {@link TExecutionMapping} Mapping having the given name.
 * /* ww w .  ja  va2s .  c  o  m*/
 * @param name
 *            name of the element to find.
 * @return any TExecutionMapping Mapping having the given name.
 */
public Iterator<TExecutionMapping> getExecutionMappings(final String name) {
    return Iterators.filter(Iterators.filter(template.eAllContents(), TExecutionMapping.class),
            new Predicate<TExecutionMapping>() {

                public boolean apply(TExecutionMapping input) {
                    return name.equals(input.getName());
                }

            });
}

From source file:test.org.mandarax.compiler.FatherRelRecords2.java

public Iterator<FatherRel> isFather(final String father, final String child) {
    Iterator<FatherRel> iterator = data.iterator();
    Predicate<FatherRel> filter = new Predicate<FatherRel>() {
        @Override/*from   ww w  .  ja v  a2 s.c o  m*/
        public boolean apply(FatherRel rel) {
            return rel.child.equals(child) && rel.father.equals(father);
        }

    };
    return Iterators.filter(iterator, filter);
}

From source file:org.caleydo.core.view.opengl.canvas.internal.swt.SWTGLCanvas.java

@Override
protected Iterator<IGLMouseListener> mouseListeners() {
    return Iterators.filter(listenerMapping.columnKeySet().iterator(), IGLMouseListener.class);
}

From source file:org.eclipse.elk.alg.layered.intermediate.greedyswitch.PortIterable.java

public Iterator<LPort> iterator() {
    final List<LPort> ports = node.getPorts();
    switch (order) {
    case CLOCKWISE:
        return node.getPorts().iterator();
    case COUNTER_CLOCKWISE:
        return Iterators.filter(getCCWIterator(ports), getPredicate());
    case NORTHSOUTH_EASTWEST:
        switch (side) {
        case EAST:
        case NORTH:
            return Iterators.filter(ports.iterator(), getPredicate());
        case SOUTH:
        case WEST:
            return Iterators.filter(getCCWIterator(ports), getPredicate());
        }/* w w  w.ja v a 2  s .  com*/
    }
    throw new UnsupportedOperationException("PortOrder not implemented.");
}

From source file:nl.knaw.huygens.timbuctoo.vre.WomenWritersVRE.java

@Override
protected Iterator<RelationType> filterRelationTypes(Iterator<RelationType> relationTypes) {

    return Iterators.filter(relationTypes, reception -> receptions.contains(reception.getRegularName()));
}

From source file:org.apache.sling.nosql.generic.simple.provider.SimpleNoSqlAdapter.java

public Iterator<NoSqlData> getChildren(String parentPath) {
    Iterator<String> keys = store.keySet().iterator();

    final Pattern childKeyPattern = PathUtil.getChildPathPattern(parentPath);
    Iterator<String> childKeys = Iterators.filter(keys, new Predicate<String>() {
        public boolean apply(String path) {
            return childKeyPattern.matcher(path).matches();
        }/*from ww  w .ja  v  a 2s  . c o m*/
    });

    return Iterators.transform(childKeys, new Function<String, NoSqlData>() {
        public NoSqlData apply(String path) {
            return get(path);
        }
    });
}

From source file:picard.vcf.processor.util.PredicateFilterDecoratingClosableIterator.java

public PredicateFilterDecoratingClosableIterator(final CloseableIterator<T> underlyingIterator,
        final Collection<Predicate<T>> predicates) {
    Preconditions.checkArgument(!predicates.isEmpty(), "predicates must not be empty");
    Iterator<T> nestedPredicateIterator = underlyingIterator;
    for (final Predicate<T> predicate : predicates) {
        nestedPredicateIterator = Iterators.filter(nestedPredicateIterator, predicate);
    }/*from  w  w w  .  jav a 2  s.com*/
    filteredIterator = nestedPredicateIterator;

    this.underlyingIterator = underlyingIterator;
}

From source file:org.eclipselabs.agrum.services.model.plugin.parser.ModelParser.java

/**
 * To get an iterator on each state of the state machine
 * @param s - the state machine/*from   www .  j a  v  a  2s. co m*/
 * @return the iterator 
 */
private static Iterator<State> StateIterator(StateMachine s) {
    Predicate<Object> allStates = Predicates.instanceOf(State.class);
    Iterator<EObject> result = Iterators.filter(s.eAllContents(), allStates);
    Iterator<State> states = Iterators.transform(result, new com.google.common.base.Function<EObject, State>() {
        @Override
        public State apply(EObject arg0) {
            return (State) arg0;
        }
    });
    return states;
}