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:org.apache.kylin.cube.cuboid.AggregationGroupScheduler.java

/**
 * Get all valid cuboids for agg group, ignoring padding
 * @param agg agg group/*from  ww w.  j av  a2  s . c  om*/
 * @return cuboidId list
 */
public static List<Long> getCuboidsForAgg(final CubeDesc cubeDesc, AggregationGroup agg) {
    Set<Long> cuboidHolder = new HashSet<>();

    // build tree structure
    Set<Long> children = getLowestCuboids(agg);
    while (!children.isEmpty()) {
        if (cuboidHolder.size() > cubeDesc.getConfig().getCubeAggrGroupMaxCombination()) {
            throw new IllegalStateException("too many combination for the aggregation group");
        }
        cuboidHolder.addAll(children);
        children = getOnTreeParentsByLayer(children, agg);
    }

    return Lists.newArrayList(Iterators.filter(cuboidHolder.iterator(), new Predicate<Long>() {
        @Override
        public boolean apply(@Nullable Long cuboidId) {
            return !cubeDesc.isBlackedCuboid(cuboidId);
        }
    }));
}

From source file:nz.ac.massey.cs.guery.AbstractGraphAdapter.java

@Override
public Iterator<E> getEdges(Predicate<? super E> filter) {
    return Iterators.filter(getEdges(), filter);
}

From source file:com.googlecode.efactory.tests.util.Find.java

/**
 * This method is for tests only, as it doesn't scale in non-test (production) code to scan an entire ResourceSet.
 *///from   w w w  .  j av a 2s . c  o  m
@Deprecated
public static <T extends EObject> Iterator<T> allInResourceSet(EObject context, Class<T> type) {
    Iterator<EObject> contentIterator = getResourceSetIterator(context);
    return Iterators.filter(contentIterator, type);
}

From source file:com.clarkparsia.sbol.SBOLUtils.java

public static DnaComponent getRootComponent(SBOLDocument doc) {
    return Iterators.getOnlyElement(Iterators.filter(doc.getContents().iterator(), DnaComponent.class), null);
}

From source file:edu.umd.cs.psl.evaluation.statistics.filter.OutOfBoundsFilter.java

@Override
public Iterator<Atom> filter(Iterator<Atom> input) {
    return Iterators.filter(input, new Predicate<Atom>() {

        @Override//  ww  w .j  a  v  a  2s  . c  o  m
        public boolean apply(Atom atom) {
            for (int i = 0; i < atom.getArity(); i++) {
                double val = atom.getSoftValue(i);
                if (val >= bounds[0] && val <= bounds[1])
                    return false;
            }
            return true;
        }

    });
}

From source file:edu.umd.cs.psl.evaluation.statistics.filter.WithinBoundsFilter.java

@Override
public Iterator<Atom> filter(Iterator<Atom> input) {
    return Iterators.filter(input, new Predicate<Atom>() {

        @Override//from  ww w.  j  a v a2  s .  c o  m
        public boolean apply(Atom atom) {
            for (int i = 0; i < atom.getArity(); i++) {
                double val = atom.getSoftValue(i);
                if (val < bounds[0] || val > bounds[1])
                    return false;
            }
            return true;
        }

    });
}

From source file:com.bitranger.parknshop.common.recommend.collections.FilteringFastIterable.java

@Override
public Iterator<E> fastIterator() {
    if (delegate instanceof FastIterable) {
        // REVIEW Is Iterators.filter really reasonable?
        Iterator<E> iter = Iterators.filter(((FastIterable<E>) delegate).fastIterator(), predicate);
        return limit(iter);
    } else {//from   w w w . j a va 2  s.c  o m
        return iterator();
    }
}

From source file:org.polarsys.reqcycle.export.transform.RequirementSourceReqProvider.java

@Override
public Iterable<Requirement> getRequirements() {
    return Lists.newArrayList(Iterators.filter(source.getContents().eAllContents(), Requirement.class));
}

From source file:nz.ac.massey.cs.guery.AbstractGraphAdapter.java

@Override
public Iterator<E> getInEdges(V vertex, Predicate<? super E> filter) {
    return Iterators.filter(getInEdges(vertex), filter);
}

From source file:com.clarkparsia.sbol.SBOLUtils.java

public static Iterator<DnaComponent> getRootComponents(SBOLDocument doc) {
    return Iterators.filter(doc.getContents().iterator(), DnaComponent.class);
}