List of usage examples for com.google.common.collect Iterables all
public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:org.gradle.testing.jacoco.tasks.JacocoReport.java
public JacocoReport() { reports = getInstantiator().newInstance(JacocoReportsContainerImpl.class, this); onlyIf(new Spec<Task>() { @Override// ww w.jav a2s . c o m public boolean isSatisfiedBy(Task element) { //TODO SF it should be 'any' instead of 'all' return Iterables.all(getExecutionData(), new Predicate<File>() { @Override public boolean apply(File file) { return file.exists(); } }); } }); }
From source file:io.crate.operation.projectors.GroupingProjector.java
private static boolean allTypesKnown(List<? extends DataType> keyTypes) { return Iterables.all(keyTypes, new Predicate<DataType>() { @Override/* w w w. ja v a 2 s . c om*/ public boolean apply(@Nullable DataType input) { return input != null && !input.equals(DataTypes.UNDEFINED); } }); }
From source file:io.crate.analyze.DeleteAnalyzedStatement.java
@Override public boolean hasNoResult() { return Iterables.all(nestedStatements, HAS_NO_RESULT_PREDICATE); }
From source file:io.crate.analyze.DeleteAnalysis.java
@Override public boolean hasNoResult() { return Iterables.all(nestedAnalysisList, HAS_NO_RESULT_PREDICATE); }
From source file:at.ac.univie.isc.asio.jaxrs.ContentNegotiationDefaultsFilter.java
private boolean containsNoConcreteType(final List<String> accepted) { return Iterables.all(accepted, new Predicate<String>() { @Override/*from w w w. ja v a 2 s . com*/ public boolean apply(final String input) { return input == null || input.equals(MediaType.WILDCARD); } }); }
From source file:com.axemblr.provisionr.amazon.activities.AllSpotRequestsMatchPredicate.java
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws Exception { LOG.info(">> Checking if all spot requests match predicate {}", predicate); @SuppressWarnings("unchecked") List<String> requestIds = (List<String>) execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS); checkNotNull(requestIds, "process variable '{}' not found", ProcessVariables.SPOT_INSTANCE_REQUEST_IDS); DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest(); describeRequest.setSpotInstanceRequestIds(requestIds); // Retrieve all of the requests we want to monitor. DescribeSpotInstanceRequestsResult describeResult = client.describeSpotInstanceRequests(describeRequest); List<SpotInstanceRequest> requests = describeResult.getSpotInstanceRequests(); if (Iterables.all(requests, predicate)) { LOG.info(">> All {} requests match predicate {} ", requests, predicate); execution.setVariable(resultVariable, true); } else {// www . j a v a 2 s. c o m LOG.info("<< Not all requests {} match predicate {}", requests, predicate); execution.setVariable(resultVariable, false); } }
From source file:org.apache.provisionr.amazon.activities.AllSpotRequestsMatchPredicate.java
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { LOG.info(">> Checking if all spot requests match predicate {}", predicate); @SuppressWarnings("unchecked") List<String> requestIds = (List<String>) execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS); checkNotNull(requestIds, "process variable '{}' not found", ProcessVariables.SPOT_INSTANCE_REQUEST_IDS); DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest(); describeRequest.setSpotInstanceRequestIds(requestIds); // Retrieve all of the requests we want to monitor. DescribeSpotInstanceRequestsResult describeResult = client.describeSpotInstanceRequests(describeRequest); List<SpotInstanceRequest> requests = describeResult.getSpotInstanceRequests(); if (Iterables.all(requests, predicate)) { LOG.info(">> All {} requests match predicate {} ", requests, predicate); execution.setVariable(resultVariable, true); } else {/*from www. ja va 2s.c o m*/ LOG.info("<< Not all requests {} match predicate {}", requests, predicate); execution.setVariable(resultVariable, false); } }
From source file:io.crate.executor.transport.StreamBucket.java
private static boolean validStreamers(Streamer<?>[] streamers) { if (streamers == null || streamers.length == 0) { return true; }/* www .j a v a 2s . co m*/ return !Iterables.all(FluentIterable.of(streamers), Predicates.isNull()); }
From source file:org.eclipse.sirius.diagram.tools.internal.validation.description.constraints.RepresentationExtensionDescriptionRegexConstraint.java
@Override public IStatus validate(IValidationContext ctx) { IStatus status = null;//from www. j a v a 2s. co m EObject target = ctx.getTarget(); if (target instanceof RepresentationExtensionDescription) { RepresentationExtensionDescription representationExtensionDescription = (RepresentationExtensionDescription) target; Matcher representationNameMatcher = REGEX_PATTERN .matcher(representationExtensionDescription.getRepresentationName()); Matcher viewpointURIMatcher = REGEX_PATTERN .matcher(representationExtensionDescription.getViewpointURI()); if (representationNameMatcher.matches() && viewpointURIMatcher.matches()) { status = ctx.createSuccessStatus(); } else { // Check that the diagram extension contains only additional // layers if (!Iterables.all(representationExtensionDescription.eContents(), Predicates.instanceOf(AdditionalLayer.class))) { status = ctx.createFailureStatus( MessageFormat.format(ERROR_MESSAGE, representationExtensionDescription.getName())); } else if (!(representationExtensionDescription instanceof DiagramExtensionDescription)) { status = ctx.createFailureStatus( MessageFormat.format(ERROR_MESSAGE, representationExtensionDescription.getName())); } else { // Check that all additional layers of diagram extension // contains only style // customizations. for (AdditionalLayer additionalLayer : ((DiagramExtensionDescription) representationExtensionDescription) .getLayers()) { if (!Iterables.all(additionalLayer.eContents(), Predicates.instanceOf(Customization.class))) { status = ctx.createFailureStatus(MessageFormat.format(ERROR_MESSAGE, representationExtensionDescription.getName())); } } } } } if (status == null) { status = ctx.createSuccessStatus(); } return status; }
From source file:org.apache.provisionr.amazon.activities.AllInstancesMatchPredicate.java
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { @SuppressWarnings("unchecked") Optional<List<String>> instanceIds = Optional .fromNullable((List<String>) execution.getVariable(ProcessVariables.INSTANCE_IDS)); if (!instanceIds.isPresent()) { LOG.warn("<< Process variable '{}' not found", ProcessVariables.INSTANCE_IDS); return;// w w w . j av a 2s.c om } else if (instanceIds.get().size() == 0) { LOG.info(">> No instances are currently registered in the process."); return; } try { DescribeInstancesResult result = client .describeInstances(new DescribeInstancesRequest().withInstanceIds(instanceIds.get())); List<Instance> instances = collectInstancesFromReservations(result.getReservations()); if (Iterables.all(instances, predicate)) { LOG.info(">> All {} instances match predicate {} ", instanceIds, predicate); execution.setVariable(resultVariable, true); } else { LOG.info("<< Not all instances {} match predicate {}", instanceIds, predicate); execution.setVariable(resultVariable, false); } } catch (AmazonServiceException exception) { if (exception.getErrorCode().equalsIgnoreCase("InvalidInstanceID.NotFound")) { LOG.warn("<< Got error InvalidInstanceID.NotFound. Assuming predicate {} is false", predicate); execution.setVariable(resultVariable, false); } else { throw Throwables.propagate(exception); } } }