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:org.asoem.greyfish.core.environment.AbstractEnvironment.java

@Override
public final Iterable<A> filterAgents(final Predicate<? super A> predicate) {
    return Iterables.filter(getActiveAgents(), predicate);
}

From source file:jflowmap.util.CollectionUtils.java

public static Iterable<Double> removeNaNs(Iterable<Double> values) {
    return Iterables.filter(values, PREDICATE_NON_NAN);
}

From source file:org.trancecode.xml.saxon.SaxonAxis.java

public static Iterable<XdmNode> childElements(final XdmNode node) {
    return Iterables.filter(childNodes(node), SaxonPredicates.isElement());
}

From source file:org.robotframework.ide.eclipse.main.plugin.tableeditor.settings.GeneralSettingsModel.java

public static List<RobotElement> findGeneralSettingsList(final RobotSettingsSection section) {
    if (section == null) {
        return newArrayList();
    }/*from ww w .java2 s .  co  m*/
    return newArrayList(
            Iterables.filter(newArrayList(fillSettingsMapping(section).values()), Predicates.notNull()));
}

From source file:com.mobogenie.framework.spring.security.SpecialRequestMatcher.java

@Override
public boolean matches(final HttpServletRequest request) {
    boolean matchMethod = !allowedMethods.matcher(request.getMethod()).matches();
    Iterable<String> filtered = Iterables.filter(list, new Predicate<String>() {
        @Override//from  ww  w  .  j  a v a 2 s  . c om
        public boolean apply(String url) {
            return getRequestPath(request).contains(url);
        }
    });
    return matchMethod && filtered.iterator().hasNext();
}

From source file:org.opentestsystem.delivery.testreg.domain.ARTHelpers.java

protected static final List<ImplicitEligibilityRule> getImplicitEligibilityRules(
        final ImplicitEligibilityRule[] implicitEligibilityRuleArray,
        final ImplicitEligibilityRule.RuleType ruleType) {
    return Lists.newArrayList(Iterables.filter(Lists.newArrayList(implicitEligibilityRuleArray),
            ImplicitEligibilityRule.RuleType.ENABLER == ruleType ? IER_ENABLER : Predicates.not(IER_ENABLER)));
}

From source file:de.faustedition.Path.java

public Path(String path) {
    super(Lists.newArrayList(
            Iterables.filter(Arrays.asList(path.replaceAll("^/+", "").replaceAll("/+$", "").split("/+")),
                    new Predicate<String>() {
                        @Override
                        public boolean apply(@Nullable String input) {
                            return !input.isEmpty();
                        }//from   w  w  w .j a  va 2  s.  co  m
                    })));
}

From source file:org.jnario.jnario.test.util.SuiteExecutor.java

protected Result runExamples(EObject object) throws MalformedURLException, ClassNotFoundException {
    SuiteFile suiteFile = (SuiteFile) object;
    CompositeResult result = new CompositeResult();
    for (Suite suite : Iterables.filter(suiteFile.getXtendTypes(), Suite.class)) {
        String suiteClassName = nameProvider.toJavaClassName(suite);
        String packageName = suiteFile.getPackage();
        result.add(runTestsInClass(suiteClassName, packageName));
    }//from   www. j av a 2s.c  om
    return result;
}

From source file:org.fusesource.ide.fabric8.ui.navigator.ProfileParentsContentProvider.java

@Override
protected List<Node> getChildrenList(final Node node) {
    if (node == null || node == this.ignoreProfileNode) {
        return Collections.EMPTY_LIST;
    }/* w  w  w  . j a va 2 s .co m*/
    return Lists.newArrayList(Iterables.filter(node.getChildrenList(), new Predicate<Node>() {

        @Override
        public boolean apply(Node that) {
            return ignoreProfileNode != that;
        }
    }));
}

From source file:org.apache.whirr.service.puppet.predicates.PuppetPredicates.java

public static Predicate<String> isLastPuppetRoleIn(final Iterable<String> roles) {
    return new Predicate<String>() {

        @Override//from  www  . java 2  s  .  com
        public boolean apply(String arg0) {
            return Iterables
                    .getLast(Iterables.filter(roles,
                            Predicates.containsPattern("^" + PUPPET_ROLE_PREFIX + arg0)))
                    .equals(PUPPET_ROLE_PREFIX + arg0);
        }

        @Override
        public String toString() {
            return "isLastPuppetRoleIn(" + roles + ")";

        }
    };

}