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:br.com.bluesoft.pronto.model.BancoDeDados.java

public List<Execucao> getExecucoesPendentes() {

    return Lists.newArrayList(Iterables.filter(execucoes, new Predicate<Execucao>() {

        @Override// w  ww  . j a va  2s  .c om
        public boolean apply(final Execucao input) {
            return input.getData() == null;
        }
    }));

}

From source file:jflowmap.util.piccolo.PNodes.java

public static final <T extends PNode> Iterable<T> childrenOfType(PNode node, Class<T> type) {
    return Iterables.filter(childrenOf(node), type);
}

From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.DestroyMessageCreationValidator.java

/**
 * Check that there is not {@link ISequenceEvent} on the target lifeline
 * with range's upperbound upper than the firstClickLocation.y .
 * //from w w w. jav a  2  s.c o  m
 * @return true if not {@link ISequenceEvent} upper than
 *         firstClickLocation.y
 */
private boolean checkNotEventAtUpperTimeInSameLifeline() {
    boolean valid = true;

    SequenceDiagram sequenceDiagram = sequenceElementSource.getDiagram();
    SequenceDiagramQuery sequenceDiagramQuery = new SequenceDiagramQuery(sequenceDiagram);

    for (ISequenceEvent sequenceEvent : Iterables.filter(
            sequenceDiagramQuery.getAllSequenceEventsUpperThan(firstClickLocation.y),
            Predicates.not(Predicates.instanceOf(Lifeline.class)))) {
        if (isSequenceEventOfLifeline(sequenceEvent, sequenceElementTarget.getLifeline())
                || isMessageTargeting(sequenceEvent, sequenceElementTarget.getLifeline())
                || isDestroyMessageFor(sequenceEvent,
                        sequenceElementTarget.getLifeline().get().getInstanceRole())) {
            valid = false;
            break;
        }
    }
    return valid;
}

From source file:org.sonar.server.platform.monitoring.PluginsMonitor.java

private Iterable<PluginInfo> plugins() {
    return Iterables.filter(repository.getPluginInfos(), new Predicate<PluginInfo>() {
        @Override//from ww  w.  j  av  a 2 s. c o  m
        public boolean apply(@Nonnull PluginInfo info) {
            return !info.isCore();
        }
    });
}

From source file:demetra.cli.tsproviders.Uri2Ts.java

@Override
public void exec(Parameters params) throws Exception {
    Iterable<ITsProvider> providers = ServiceLoader.load(ITsProvider.class);
    for (IFileLoader o : Iterables.filter(providers, IFileLoader.class)) {
        ProviderTool.getDefault().applyWorkingDir(o);
    }//from  w  w  w . j av  a2  s  . co m
    TsCollectionInformation result = ProviderTool.getDefault().getTsCollection(providers, params.uri,
            TsInformationType.All);
    XmlUtil.writeValue(params.output, XmlTsCollection.class, result);
    for (ITsProvider o : providers) {
        o.dispose();
    }
}

From source file:com.palantir.common.base.AbortingVisitors.java

/**
 * @deprecated in favor of {@link BatchingVisitableView#filter(Predicate)}
 *///from w  w w .  ja v  a2 s .com
@Deprecated
public static <T, K extends Exception> AbortingVisitor<Iterable<T>, K> filterBatch(
        final AbortingVisitor<? super List<T>, K> v, final Predicate<? super T> p) {
    return new AbortingVisitor<Iterable<T>, K>() {
        @Override
        public boolean visit(Iterable<T> item) throws K {
            List<T> list = ImmutableList.copyOf(Iterables.filter(item, p));
            if (list.isEmpty()) {
                return true;
            } else {
                return v.visit(list);
            }
        }
    };
}

From source file:eu.numberfour.n4js.analysis.ExceptionAnalyser.java

@Override
protected List<Diagnostic> getScriptErrors(Script script) {
    EcoreUtil.resolveAll(script.eResource());
    List<Diagnostic> diagnostics = super.getScriptErrors(script);
    Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
    List<Diagnostic> result = Lists
            .<Diagnostic>newArrayList(Iterables.filter(diagnostics, ExceptionDiagnostic.class));
    while (expressions.hasNext()) {
        Expression expression = expressions.next();
        RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
        Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
        if (type.getRuleFailedException() != null) {
            Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
            if (!(cause instanceof RuleFailedException)) {
                if (cause instanceof Exception) {
                    result.add(new ExceptionDiagnostic((Exception) cause));
                } else {
                    throw new RuntimeException(cause);
                }//from  w w  w  . j av  a 2  s  .  c o m
            }
        }
    }
    validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
    return result;
}

From source file:edu.illinois.cs.cogcomp.wikifier.utils.io.StopWords.java

public Iterable<String> filter(Iterable<String> words) {
    if (words == null)
        return null;
    return Iterables.filter(words, this);
}

From source file:org.obiba.opal.core.cfg.OpalConfiguration.java

public <T extends OpalConfigurationExtension> T getExtension(Class<T> type) {
    try {/* www .  jav  a2s  .  com*/
        return Iterables.getOnlyElement(Iterables.filter(extensions, type));
    } catch (IndexOutOfBoundsException e) {
        throw new NoSuchElementException();
    }
}

From source file:org.summer.dsl.xbase.scoping.featurecalls.FilteredDelegatingScope.java

@Override
protected Iterable<IEObjectDescription> getLocalElementsByEObject(EObject object, URI uri) {
    Iterable<IEObjectDescription> result = getDelegate().getElements(object);
    return Iterables.filter(result, this);
}