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:com.proofpoint.cloudmanagement.service.ProviderLocationResource.java

private boolean providerHasLocationAvailable(String provider, final String location) {
    return Iterables.any(instanceConnectorMap.get(provider).getLocations(), new Predicate<Location>() {
        @Override/*from w  ww.j  a v  a  2 s.c  o  m*/
        public boolean apply(@Nullable Location input) {
            return input.getLocation().equals(location);
        }
    });
}

From source file:com.marvelution.bamboo.plugins.sonar.tasks.actions.admin.ViewSonarServerMatrix.java

public Map<String, Map<Integer, Boolean>> getServerMatrix() {
    if (matrix == null) {
        matrix = Maps.newHashMap();//  w  ww . j  a  v a  2s  . co m
        for (Buildable buildable : getBuildables()) {
            Map<Integer, Boolean> serverMatches = Maps.newHashMap();
            for (SonarServer server : getServers()) {
                serverMatches.put(server.getID(),
                        Iterables.any(buildable.getBuildDefinition().getTaskDefinitions(),
                                SonarPredicates.isSonarServerDependingTask(server)));
            }
            matrix.put(buildable.getKey(), serverMatches);
        }
    }
    return matrix;
}

From source file:org.jclouds.compute.ComputeServiceContextBuilder.java

protected void addImageResolutionModuleIfNotPresent() {
    if (!Iterables.any(modules, new Predicate<Module>() {
        public boolean apply(Module input) {
            return input.getClass().isAnnotationPresent(ResolvesImages.class);
        }//from  www.j  ava 2s . c om

    })) {
        addImageResolutionModule();
    }
}

From source file:com.spotify.helios.client.EndpointIterator.java

/**
 * @return true if any endpoints' scheme is HTTPS
 *///from   w ww.  j  a  va 2s  .  c o  m
boolean hasHttps() {
    return Iterables.any(endpoints, new Predicate<Endpoint>() {
        @Override
        public boolean apply(@Nullable Endpoint endpoint) {
            return endpoint != null && endpoint.getUri() != null && endpoint.getUri().getScheme() != null
                    && endpoint.getUri().getScheme().equalsIgnoreCase("https");
        }
    });
}

From source file:org.opensaml.storage.impl.client.ClientStorageSaveContext.java

/**
 * Get whether a particular storage source is implicated by the queued operations.
 * //w  ww .jav a2  s.  co  m
 * @param source storage source to check for
 * @return true iff the operations include at least one against the specified source
 */
public boolean isSourceRequired(@Nonnull final ClientStorageSource source) {
    return Iterables.any(storageOperations, new Predicate<ClientStorageServiceOperation>() {
        public boolean apply(ClientStorageServiceOperation input) {
            return input.getStorageSource() == source;
        }
    });
}

From source file:com.radeonsys.data.querystore.support.CompositeQueryStore.java

@Override
public boolean containsQuery(final String queryName) {
    return Iterables.any(stores, new Predicate<QueryStore>() {
        @Override//  ww w  .  j  a  va  2 s .com
        public boolean apply(QueryStore store) {
            return store.containsQuery(queryName);
        }
    });
}

From source file:org.apache.kylin.dimension.DimensionEncodingFactory.java

public static boolean isValidEncoding(final String encodingName) {
    if (factoryMap == null)
        initFactoryMap();//from   ww w  .ja v a  2 s  . co  m

    // note dictionary is a special case
    return DictionaryDimEnc.ENCODING_NAME.equals(encodingName) || //
            Iterables.any(factoryMap.keySet(), new Predicate<Pair<String, Integer>>() {
                @Override
                public boolean apply(@Nullable Pair<String, Integer> input) {
                    return input.getFirst().equals(encodingName);
                }
            });
}

From source file:gobblin.metrics.metric.filter.MetricTypeFilter.java

@Override
public boolean matches(String name, Metric metric) {
    final Class<? extends Metric> metricClass = metric.getClass();

    return Iterables.any(this.allowedMetrics, new Predicate<Metrics>() {
        @Override// w w  w .  j a va 2 s  .com
        public boolean apply(@Nullable Metrics input) {
            return input != null && input.getMetricClass().isAssignableFrom(metricClass);
        }
    });
}

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

public static boolean checkFeatureAnnotation(EStructuralFeature feature, final String patternFQN) {
    return Iterables.any(feature.getEAnnotations(), annotation -> {
        if (QueryBasedFeatures.ANNOTATION_SOURCE.equals(annotation.getSource())) {
            return Iterables.any(annotation.getDetails().entrySet(), entry -> {
                boolean keyOK = QueryBasedFeatures.PATTERN_FQN_KEY.equals(entry.getKey());
                boolean valueOK = patternFQN.equals(entry.getValue());
                return keyOK && valueOK;
            });//from w w  w. j a v a2  s .  c  om
        }
        return false;
    });
}

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

public boolean supportsJmx() {
    boolean pre062 = Iterables.any(getAgentConfConventionValue(), new Predicate<File>() {
        @Override/*from w  w  w. ja va  2  s .c o m*/
        public boolean apply(File file) {
            return V_0_6_2_0.compareTo(extractVersion(file.getName())) > 0;
        }
    });
    return !pre062;
}