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

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

Introduction

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

Prototype

public static <T> boolean any(Iterable<T> iterable, Predicate<? super T> predicate) 

Source Link

Document

Returns true if any element in iterable satisfies the predicate.

Usage

From source file:org.gradle.internal.jacoco.JacocoAgentJar.java

public boolean supportsInclNoLocationClasses() {
    boolean pre076 = Iterables.any(getAgentConfConventionValue(), new Predicate<File>() {
        @Override/*  ww w  .ja  v  a2s.  c o  m*/
        public boolean apply(File file) {
            return V_0_7_6_0.compareTo(extractVersion(file.getName())) > 0;
        }
    });
    return !pre076;
}

From source file:org.eclipse.buildship.ui.view.task.TaskViewActionStateRules.java

private static boolean hasMultipleOrIncludedParentProject(List<TaskNode> nodes) {
    Preconditions.checkArgument(!nodes.isEmpty());
    final ProjectNode firstParent = nodes.get(0).getParentProjectNode();
    if (firstParent.isIncludedProject()) {
        return true;
    }/*w ww . ja  v  a  2  s  . co m*/
    return Iterables.any(nodes, new Predicate<TaskNode>() {

        @Override
        public boolean apply(TaskNode node) {
            return !node.getParentProjectNode().equals(firstParent);
        }
    });
}

From source file:com.google.testing.compile.Parser.java

/**
 * Returns {@code true} if errors were found while parsing source files.
 *
 * <p>Normally, the parser reports error diagnostics, but in some cases there are no diagnostics;
 * instead the parse tree contains {@linkplain ErroneousTree "erroneous"} nodes.
 *///from   w w  w .j  av a2 s.c o m
private static boolean foundParseErrors(Iterable<? extends CompilationUnitTree> parsedCompilationUnits,
        List<Diagnostic<? extends JavaFileObject>> diagnostics) {
    return diagnostics.stream().map(Diagnostic::getKind).anyMatch(isEqual(ERROR))
            || Iterables.any(parsedCompilationUnits, Parser::hasErrorNode);
}

From source file:com.facebook.presto.util.IterableTransformer.java

public boolean any(Predicate<E> predicate) {
    return Iterables.any(iterable, predicate);
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.utils.SonarTaskUtils.java

/**
 * Get all the {@link Job}s that have a Sonar Task the specified {@link Predicate}
 * /*from  w w w . j a v  a 2 s  .c o m*/
 * @param plan the {@link Plan} to get the {@link Job}s from
 * @param predicate the {@link Predicate} to use
 * @return the {@link List} of {@link Job}s
 */
public static List<Job> getJobsWithSonarTasks(Plan plan, Predicate<TaskDefinition> predicate) {
    List<Job> jobs = Lists.newArrayList();
    if (plan instanceof Chain) {
        for (Job job : ((Chain) plan).getAllJobs()) {
            if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(), predicate)) {
                jobs.add(job);
            }
        }
    } else if (plan instanceof Buildable) {
        Job job = (Job) plan;
        if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(), predicate)) {
            jobs.add(job);
        }
    }
    return jobs;
}

From source file:nerds.antelax.commons.net.pubsub.PubSubServerContextListener.java

@Override
public synchronized void contextInitialized(final ServletContextEvent ctx) {
    final ServletContext sc = ctx.getServletContext();
    final Collection<InetSocketAddress> cluster = sc != null ? NetUtil.hostPortPairsFromString(
            sc.getInitParameter(CLUSTER_INIT_PARAM), PubSubServer.DEFAULT_ADDRESS.getPort()) : EMPTY;
    REMOTE_SERVERS.set(Collections2.filter(cluster, Predicates.not(NetUtil.machineLocalSocketAddress())));
    if (Iterables.any(cluster, NetUtil.machineLocalSocketAddress())) {
        server = new PubSubServer(cluster);
        ctx.getServletContext()/*from  w  w  w  .  jav a 2 s  . c o m*/
                .log("Starting PubSub server, this machine is part of the cluster definition[" + cluster + "]");
        server.start();
    } else {
        server = null;
        ctx.getServletContext()
                .log("No PubSub server started, remotes available for final clients are " + remoteServers());
    }
}

From source file:org.eclipse.incquery.querybasedfeatures.runtime.handler.QueryBasedFeatures.java

public static boolean checkFeatureAnnotation(EStructuralFeature feature, final String patternFQN) {
    return Iterables.any(feature.getEAnnotations(), new Predicate<EAnnotation>() {
        @Override/*  www .j  a v  a  2 s  . c  o m*/
        public boolean apply(EAnnotation annotation) {
            if (QueryBasedFeatures.ANNOTATION_SOURCE.equals(annotation.getSource())) {
                return Iterables.any(annotation.getDetails().entrySet(),
                        new Predicate<Entry<String, String>>() {
                            @Override
                            public boolean apply(Entry<String, String> entry) {
                                boolean keyOK = QueryBasedFeatures.PATTERN_FQN_KEY.equals(entry.getKey());
                                boolean valueOK = patternFQN.equals(entry.getValue());
                                return keyOK && valueOK;
                            }
                        });
            }
            return false;
        }
    });
}

From source file:org.richfaces.ui.iteration.tree.DeclarativeTreeDataModelImpl.java

public boolean isLeaf() {
    UIComponent currentComponent = getCurrentComponent();

    TreeModelAdaptor adaptor = (TreeModelAdaptor) currentComponent;

    if (adaptor.isLeaf()) {
        return true;
    }/* w  ww .  j  ava  2  s  .c  o  m*/

    if (adaptor instanceof TreeModelRecursiveAdaptor) {
        return false;
    }

    if (currentComponent.getChildCount() == 0) {
        return true;
    }

    return !Iterables.any(currentComponent.getChildren(), TREE_MODEL_ADAPTOR_INSTANCE_PREDICATE);
}

From source file:org.opentestsystem.authoring.testauth.service.impl.ItemBaseHelper.java

protected boolean hasLocation(final Item item, final ItemLocation location) {
    return Iterables.any(item.getItemLocation(), ItemLocation.SAME_LOCATION_FINDER.getInstance(location));
}

From source file:org.eclipse.emf.compare.uml2.internal.postprocessor.util.UMLCompareUtil.java

private static Predicate<? super EReference> isNonUnionReference() {
    return new Predicate<EReference>() {
        public boolean apply(EReference input) {
            return input != null
                    && !Iterables.any(input.getEAnnotations(), UMLUtilForCompare.isUnionAnnotation());
        }/*w  w  w. ja  v  a  2s  .c o  m*/
    };
}