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

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

Introduction

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

Prototype

public static boolean contains(Iterable<?> iterable, @Nullable Object element) 

Source Link

Document

Returns true if iterable contains any object for which equals(element) is true.

Usage

From source file:com.forerunnergames.tools.common.Arguments.java

private static boolean hasNullValues(final Map<?, ?> map) {
    return map != null && Iterables.contains(map.values(), null);
}

From source file:org.apache.cassandra.db.compaction.CompactionManager.java

/**
 * Try to stop all of the compactions for given ColumnFamilies.
 *
 * Note that this method does not wait for all compactions to finish; you'll need to loop against
 * isCompacting if you want that behavior.
 *
 * @param columnFamilies The ColumnFamilies to try to stop compaction upon.
 * @param interruptValidation true if validation operations for repair should also be interrupted
 *
 *//*from ww  w . jav a 2  s  . c  o m*/
public void interruptCompactionFor(Iterable<CFMetaData> columnFamilies, boolean interruptValidation) {
    assert columnFamilies != null;

    // interrupt in-progress compactions
    for (Holder compactionHolder : CompactionMetrics.getCompactions()) {
        CompactionInfo info = compactionHolder.getCompactionInfo();
        if ((info.getTaskType() == OperationType.VALIDATION) && !interruptValidation)
            continue;

        if (Iterables.contains(columnFamilies, info.getCFMetaData()))
            compactionHolder.stop(); // signal compaction to stop
    }
}

From source file:com.cloud.bridge.service.jclouds.JCloudsEC2Engine.java

/**
 * More than one place we need to access the defined list of zones.  If given a specific
 * list of zones of interest, then only values from those zones are returned.
 *
 * @param interestedZones - can be null, should be a subset of all zones
 *
 * @return EC2DescribeAvailabilityZonesResponse
 *//*from  w w w .jav a2 s.c o  m*/
private EC2DescribeAvailabilityZonesResponse listZones(Iterable<String> interestedZones) throws Exception {
    EC2DescribeAvailabilityZonesResponse zones = new EC2DescribeAvailabilityZonesResponse();
    if (Iterables.size(interestedZones) == 0 || Iterables.contains(interestedZones, "default")) {
        zones.addZone("default", "default");
    }
    return zones;
}

From source file:com.cloud.bridge.service.jclouds.JCloudsEC2Engine.java

/**
 * More than one place we need to access the defined list of zones.  If given a specific
 * list of zones of interest, then only values from those zones are returned.
 *
 * @param interestedZones - can be null, should be a subset of all zones
 *
 * @return EC2DescribeAvailabilityZonesResponse
 *///from  ww w.  jav  a 2s  .co  m
private EC2DescribeRegionsResponse listRegions(Iterable<String> interestedRegions) throws Exception {
    EC2DescribeRegionsResponse regions = new EC2DescribeRegionsResponse();
    for (Reference orgRef : getApi().getOrgApi().list()) {
        Org org = getApi().getOrgApi().get(orgRef.getHref());
        if (Iterables.size(interestedRegions) == 0 || Iterables.contains(interestedRegions, org.getId()))
            regions.addRegion(org.getId(), org.getName());
    }
    return regions;
}