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.obiba.onyx.quartz.core.engine.questionnaire.question.Attributes.java

/**
 * @param attributes//from   w  w w  .java 2 s.c om
 * @param namespace
 * @param name
 * @return
 */
public static boolean containsAttribute(List<Attribute> attributes, String namespace, String name) {
    return Iterables.any(attributes, predicate(namespace, name));
}

From source file:org.apache.cassandra.streaming.StreamState.java

public boolean hasFailedSession() {
    return Iterables.any(sessions, new Predicate<SessionInfo>() {
        public boolean apply(SessionInfo session) {
            return session.isFailed();
        }//from w w w. j a  v a2  s  . com
    });
}

From source file:org.lealone.cluster.streaming.StreamState.java

public boolean hasFailedSession() {
    return Iterables.any(sessions, new Predicate<SessionInfo>() {
        @Override/*ww w . jav a  2s  . c o m*/
        public boolean apply(SessionInfo session) {
            return session.isFailed();
        }
    });
}

From source file:org.jclouds.cloudstack.predicates.SecurityGroupPredicates.java

/**
 * /*www.  j  a  v a 2  s .co m*/
 * @return true, if the security group contains an ingress rule with the given cidr
 */
public static Predicate<SecurityGroup> hasCidr(final String cidr) {
    return new Predicate<SecurityGroup>() {

        @Override
        public boolean apply(SecurityGroup group) {
            return Iterables.any(group.getIngressRules(), new Predicate<IngressRule>() {
                @Override
                public boolean apply(IngressRule rule) {
                    return rule.getCIDR() != null && rule.getCIDR().equals(cidr);
                }
            });
        }

        @Override
        public String toString() {
            return "hasCidr(" + cidr + ")";
        }
    };
}

From source file:forge.game.staticability.StaticAbilityCantAttackBlock.java

/**
 * TODO Write javadoc for this method./*  w w  w . j  a v  a  2 s.c o  m*/
 * 
 * @param stAb
 *            a StaticAbility
 * @param card
 *            the card
 * @return a Cost
 */
public static boolean applyCantAttackAbility(final StaticAbility stAb, final Card card,
        final GameEntity target) {
    final Map<String, String> params = stAb.getMapParams();
    final Card hostCard = stAb.getHostCard();

    if (params.containsKey("ValidCard")
            && !card.isValid(params.get("ValidCard").split(","), hostCard.getController(), hostCard)) {
        return false;
    }

    if (params.containsKey("Target")
            && !target.isValid(params.get("Target").split(","), hostCard.getController(), hostCard)) {
        return false;
    }

    final Player defender = target instanceof Card ? ((Card) target).getController() : (Player) target;

    if (params.containsKey("UnlessDefenderControls")) {
        String type = params.get("UnlessDefenderControls");
        CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield);
        if (Iterables.any(list,
                CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) {
            return false;
        }
    }
    if (params.containsKey("IfDefenderControls")) {
        String type = params.get("IfDefenderControls");
        CardCollectionView list = defender.getCardsIn(ZoneType.Battlefield);
        if (!Iterables.any(list,
                CardPredicates.restriction(type.split(","), hostCard.getController(), hostCard))) {
            return false;
        }
    }
    if (params.containsKey("DefenderNotNearestToYouInChosenDirection") && hostCard.getChosenDirection() != null
            && defender.equals(hostCard.getGame().getNextPlayerAfter(card.getController(),
                    hostCard.getChosenDirection()))) {
        return false;
    }
    if (params.containsKey("UnlessDefender")) {
        final String type = params.get("UnlessDefender");
        if (defender.hasProperty(type, hostCard.getController(), hostCard)) {
            return false;
        }
    }

    return true;
}

From source file:ext.deployit.community.cli.plainarchive.matcher.CarMatcher.java

private static boolean containsLibraries(TFile car) {
    final String nameSuffixToMatch = "." + LIBRARY_EXTENSION;
    return Iterables.any(listFiles(new TFile(car, LIBRARY_DIR)), new Predicate<File>() {
        @Override/*from w w  w.ja  va  2  s . c o m*/
        public boolean apply(File input) {
            return input.getName().endsWith(nameSuffixToMatch);
        }
    });
}

From source file:com.eucalyptus.tags.TagHelper.java

/**
 * Check if the tag is reserved in the given context.
 *
 * @param tagName The tag name to check.
 * @return true if reserved (not permitted for C_UD)
 * @see Contexts#lookup/*from w  w  w  .  ja va2 s.  c  o m*/
 */
public static boolean isReserved(final String tagName) {
    return !Contexts.lookup().isPrivileged() && Iterables.any(reservedPrefixes, prefix(tagName));
}

From source file:pt.ist.maidSyncher.domain.github.GHLabel.java

public static boolean containsDeletedLabel(Collection<GHLabel> labelsToSearch) {
    return Iterables.any(labelsToSearch, new Predicate<GHLabel>() {
        @Override//from   w  w  w  .j a va 2 s  . com
        public boolean apply(GHLabel ghLabel) {
            if (ghLabel == null)
                return false;
            return ghLabel.getName().equalsIgnoreCase(DELETED_LABEL_NAME);

        }
    });
}

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

/**
 * Check if a given {@link Plan} has any Sonar Tasks configured
 * //from   www  .  j  a v a  2  s . co  m
 * @param plan the {@link Plan} to check
 * @param predicate the {@link Predicate} to use
 * @return <code>true</code> if found, <code>false</code> otherwise
 */
public static boolean hasSonarTasks(Plan plan, Predicate<TaskDefinition> predicate) {
    if (plan instanceof Chain) {
        LOGGER.debug("The Plan is a Chain, get all the Jobs that have a Sonar Task");
        for (Job job : ((Chain) plan).getAllJobs()) {
            if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(), predicate)) {
                return true;
            }
        }
    } else if (plan instanceof Buildable) {
        LOGGER.debug("The Plan is a Buildable, check if it has a Sonar Task");
        Job job = (Job) plan;
        if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(), predicate)) {
            return true;
        }
    }
    return false;
}

From source file:com.allogy.couch.filter.ExcludeRevisionExistsDocumentFilter.java

public boolean includeDocument(CouchDbConnector couchDbConnector, String documentId, final String revision) {
    if (!couchDbConnector.contains(documentId))
        return true;

    List<Revision> revisions = couchDbConnector.getRevisions(documentId);

    return !Iterables.any(revisions, new Predicate<Revision>() {
        public boolean apply(@Nullable Revision existingRevision) {
            if (existingRevision == null)
                return false;
            return revision.equals(existingRevision.getRev());
        }//www .  j  a v  a2  s  .  c  o m
    });
}