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.google.enterprise.connector.pusher.DocUtils.java

/**
 * Returns true if the document exposes any acl properties, false otherwise.
 *//*from   ww w  . j  a va2  s . c  om*/
public static boolean hasAclProperties(Document document) throws RepositoryException {
    return Iterables.any(document.getPropertyNames(), aclPredicate);
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.providers.decorators.SubDiagramDecorator.java

private boolean shouldHaveSubDiagDecoration(DRepresentationElement node) {
    EObject target = node.getTarget();// ww  w. j av a 2 s .  c  o m
    boolean shouldHaveSubDiagramDecorator = false;
    if (target != null && target.eResource() != null) {

        if (session != null && !parentHasSameSemanticElement(node)) {
            // Does the target element has any representation on it? Exclude
            // the current representation itself to avoid redundant markers.
            DRepresentation representation = new DRepresentationElementQuery(node).getParentRepresentation();
            Predicate<DRepresentation> otherReperesentation = Predicates
                    .not(Predicates.equalTo(representation));
            shouldHaveSubDiagramDecorator = Iterables
                    .any(DialectManager.INSTANCE.getRepresentations(target, session), otherReperesentation);
            if (node.getMapping() != null && !shouldHaveSubDiagramDecorator) {
                shouldHaveSubDiagramDecorator = checkRepresentationNavigationDescriptions(node);
            }
        }
    }
    return shouldHaveSubDiagramDecorator;
}

From source file:org.apache.jackrabbit.oak.plugins.document.MissingLastRevSeeker.java

public boolean isRecoveryNeeded() {
    return Iterables.any(getAllClusters(), isRecoveryNeeded);
}

From source file:org.sosy_lab.cpachecker.cpa.bam.BAMTransferRelationWithFixPointForRecursion.java

private Collection<? extends AbstractState> doFixpointIterationForRecursion(
        final AbstractState pHeadOfMainFunctionState, final Precision pPrecision,
        final CFANode pHeadOfMainFunction) throws CPAException, InterruptedException {

    assert isHeadOfMainFunction(pHeadOfMainFunction) && stack.isEmpty();

    Collection<? extends AbstractState> resultStates;
    int iterationCounter = 0;
    while (true) { // fixpoint-iteration to handle recursive functions

        if (!targetFound) {
            // The target might be outside the recursive function.
            // If CEGAR removes the target through refinement,
            // we might miss the recursive function, if we reset the flags. So we do not reset them in that case.

            recursionSeen = false; // might be changed in recursive analysis
            resultStatesChanged = false; // might be changed in recursive analysis
            potentialRecursionUpdateStates.clear();
        }//from w w  w  .jav  a 2  s.  c  o  m

        logger.log(Level.FINEST, "Starting recursive analysis of main-block");

        resultStates = doRecursiveAnalysis(pHeadOfMainFunctionState, pPrecision, pHeadOfMainFunction);

        logger.log(Level.FINEST, "Finished recursive analysis of main-block");

        // EITHER: result is an target-state, return it 'as is' and let CEGAR-algorithm perform a refinement, if needed.
        // OR:     we have completely analyzed the main-block and have not found an target-state.
        //         now we check, if we need to unwind recursive calls further until a fixpoint is reached.

        targetFound = Iterables.any(resultStates, IS_TARGET_STATE);
        if (targetFound) {
            // not really a fixpoint, but we return and let CEGAR check the target-state
            logger.log(Level.INFO, "fixpoint-iteration aborted, because there was a target state.");
            break;
        }

        if (!resultStatesChanged) {
            logger.log(Level.INFO,
                    "fixpoint-iteration aborted, because we did not get new states (fixpoint reached).");
            break;
        }

        logger.log(Level.INFO, "fixpoint was not reached, starting new iteration", ++iterationCounter);

        reAddStatesForFixPointIteration(pHeadOfMainFunctionState);

        // continue;
    }

    return resultStates;
}

From source file:org.opennms.features.topology.app.internal.info.GenericInfoPanelItemProvider.java

@Override
public Collection<InfoPanelItem> getContributions(final GraphContainer container) {
    try (final DirectoryStream<Path> stream = Files.newDirectoryStream(DIR, "*.html")) {
        final Set<InfoPanelItem> items = Sets.newHashSet();
        for (final Path path : stream) {
            try {
                final RenderResult result = this.render(path, container);

                if (Iterables.any(result.getErrors(), e -> e.getSeverity() == TemplateError.ErrorType.FATAL)) {
                    // Only show the errors to the user if there are real errors, ignoring warnings
                    items.add(new ErrorItem(path, result.getErrors()));

                } else if ((Boolean) result.getContext().getOrDefault("visible", false)) {
                    items.add(new TemplateItem(result));
                }//from   ww w . j a  va  2s . c om

            } catch (final IOException e) {
                LOG.error("Failed to load template: {}: {}", path, e);
                return Collections.emptySet();
            }
        }
        return items;
    } catch (final IOException e) {
        LOG.error("Failed to walk template directory: {}", DIR);
        return Collections.emptySet();
    }
}

From source file:com.android.tools.idea.avdmanager.DeviceManagerConnection.java

/**
 * Return true iff the given device matches one of the user declared devices.
 *///from  ww  w . ja  va 2 s.c om
public boolean isUserDevice(@NotNull final Device device) {
    if (!initIfNecessary()) {
        return false;
    }
    return Iterables.any(ourDeviceManager.getDevices(DeviceManager.DeviceFilter.USER), new Predicate<Device>() {
        @Override
        public boolean apply(Device input) {
            return device.getId().equalsIgnoreCase(input.getId());
        }
    });
}

From source file:org.eclipse.emf.compare.rcp.ui.internal.contentmergeviewer.accessor.impl.ManyStructuralFeatureAccessorImpl.java

private boolean isPartOfConflictWithDelete(final Diff diff) {
    if (diff.getConflict() == null) {
        return false;
    }//www  . j  a va  2  s  . c  om
    return Iterables.any(diff.getConflict().getDifferences(), new Predicate<Diff>() {
        public boolean apply(Diff aDiff) {
            return diff != aDiff && aDiff.getKind() == DifferenceKind.DELETE;
        }
    });
}

From source file:org.killbill.billing.payment.core.sm.payments.PaymentLeavingStateCallback.java

protected void validateUniqueTransactionExternalKey(
        final List<PaymentTransactionModelDao> existingPaymentTransactions) throws PaymentApiException {
    // If no key specified, system will allocate a unique one later, there is nothing to check
    if (paymentStateContext.getPaymentTransactionExternalKey() == null) {
        return;//  w w  w.jav a2  s.  c o m
    }

    if (Iterables.any(existingPaymentTransactions, new Predicate<PaymentTransactionModelDao>() {
        @Override
        public boolean apply(final PaymentTransactionModelDao input) {
            // An existing transaction in a SUCCESS state
            return input.getTransactionStatus() == TransactionStatus.SUCCESS ||
            // Or, an existing transaction for a different payment (to do really well, we should also check on paymentExternalKey which is not available here)
            (paymentStateContext.getPaymentId() != null
                    && input.getPaymentId().compareTo(paymentStateContext.getPaymentId()) != 0) ||
            // Or, an existing transaction for a different account.
            (!input.getAccountRecordId()
                    .equals(paymentStateContext.getInternalCallContext().getAccountRecordId()));

        }
    })) {
        throw new PaymentApiException(ErrorCode.PAYMENT_ACTIVE_TRANSACTION_KEY_EXISTS,
                paymentStateContext.getPaymentTransactionExternalKey());
    }
}

From source file:com.twitter.aurora.scheduler.configuration.ConfigurationManager.java

public static boolean isDedicated(ITaskConfig task) {
    return Iterables.any(task.getConstraints(), getConstraintByName(DEDICATED_ATTRIBUTE));
}

From source file:org.terasology.manualLabor.processParts.SymmetricBlockInputProcessPartCommonSystem.java

@ReceiveEvent
public void validateInventoryItem(ProcessEntityIsInvalidForInventoryItemEvent event, EntityRef processEntity,
        SymmetricBlockInputComponent symmetricBlockInputComponent) {
    if (WorkstationInventoryUtils
            .getAssignedInputSlots(event.getWorkstation(),
                    InventoryInputProcessPartCommonSystem.WORKSTATIONINPUTCATEGORY)
            .contains(event.getSlotNo())
            && !Iterables.any(getInputItemsFilter(symmetricBlockInputComponent).keySet(),
                    x -> x.apply(event.getItem()))) {
        event.consume();//  w w  w  . j  av  a 2  s .c  o  m
    }
}