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

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

Introduction

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

Prototype

public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate) 

Source Link

Document

Returns true if every element in iterable satisfies the predicate.

Usage

From source file:com.axemblr.provisionr.amazon.core.ImageTableQuery.java

boolean matchesFilters(final Map<String, String> row, Map<String, String> filters) {
    return Iterables.all(filters.entrySet(), new Predicate<Map.Entry<String, String>>() {
        @Override//ww w.  j  av  a 2s.  co  m
        public boolean apply(Map.Entry<String, String> entry) {
            return Objects.equal(row.get(entry.getKey()), entry.getValue());
        }
    });
}

From source file:de.cosmocode.commons.validation.AbstractRule.java

@Override
public boolean all(Iterable<? extends T> inputs) {
    Preconditions.checkNotNull(inputs, "Inputs");
    return Iterables.all(inputs, this);
}

From source file:com.axemblr.provisionr.core.activities.CheckProcessesEnded.java

@Override
public void execute(DelegateExecution execution) throws Exception {
    @SuppressWarnings("unchecked")
    List<String> processIds = (List<String>) execution.getVariable(variableWithProcessIds);

    final boolean allDone = Iterables.all(processIds, new Predicate<String>() {
        @Override//  w ww.ja v a 2s .co  m
        public boolean apply(String instanceId) {
            ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId)
                    .singleResult();

            return instance == null || instance.isEnded();
        }
    });

    LOG.info("CheckProcessesEnded {}: {}", processIds, allDone);
    execution.setVariable(resultVariable, allDone);
}

From source file:org.bonitasoft.studio.contract.ui.wizard.FieldToContractInputMappingViewerCheckStateManager.java

@Override
public boolean isGrayed(final Object element) {
    final FieldToContractInputMapping mapping = (FieldToContractInputMapping) element;
    return any(mapping.getChildren(), isGenerated()) && !Iterables.all(mapping.getChildren(), isGenerated());
}

From source file:uk.ac.ed.inf.ace.utils.SparseMatrix.java

@Override
public void putAll(Map<? extends List<K>, ? extends V> m) {
    Preconditions.checkState(Iterables.all(m.keySet(), CORRECT_SIZE), "Dimensions mismatch");
    super.putAll(m);
}

From source file:com.analog.lyric.dimple.solvers.sumproduct.customFactors.CustomMultivariateNormalConstantParameters.java

/**
 * Utility to indicate whether or not a factor is compatible with the requirements of this custom factor
 * @deprecated as of release 0.08/*from ww  w.  j ava  2s  .  c  om*/
 */
@Deprecated
public static boolean isFactorCompatible(Factor factor) {
    FactorFunction factorFunction = factor.getFactorFunction();
    MultivariateNormal specificFactorFunction = (MultivariateNormal) factorFunction;

    if (!specificFactorFunction.hasConstantParameters())
        return false;

    return Iterables.all(factor.getSiblings(), VariablePredicates.isUnboundedRealJoint());
}

From source file:com.analog.lyric.dimple.solvers.sumproduct.customFactors.GaussianFactorBase.java

/**
 * Asserts that factor has only unbounded Real variables.
 * <p>/*w  w  w .j  av  a2 s .c  o m*/
 * For use in subclass constructors.
 * <p>
 * @throws SolverFactorCreationException if assertion fails.
 * @since 0.08
 */
protected void assertUnboundedReal(Factor factor) {
    if (!Iterables.all(factor.getSiblings(), VariablePredicates.isUnboundedReal())) {
        throw new SolverFactorCreationException("Cannot use %s with %s: not all variables are unbounded Real",
                getClass().getSimpleName(), factor);
    }
}

From source file:hudson.plugins.emailext.plugins.recipients.RecipientProviderUtilities.java

public static Set<User> getChangeSetAuthors(final Collection<Run<?, ?>> runs, final IDebug debug) {
    debug.send("  Collecting change authors...");
    final Set<User> users = new HashSet<>();
    for (final Run<?, ?> run : runs) {
        debug.send("    build: %d", run.getNumber());
        if (run instanceof AbstractBuild<?, ?>) {
            final ChangeLogSet<?> changeLogSet = ((AbstractBuild<?, ?>) run).getChangeSet();
            if (changeLogSet == null) {
                debug.send("      changeLogSet was null");
            } else {
                addChangeSetUsers(changeLogSet, users, debug);
            }//from   ww w.ja v  a2 s  . c  o m
        } else {
            try {
                Method getChangeSets = run.getClass().getMethod("getChangeSets");
                if (List.class.isAssignableFrom(getChangeSets.getReturnType())) {
                    @SuppressWarnings("unchecked")
                    List<ChangeLogSet<ChangeLogSet.Entry>> sets = (List<ChangeLogSet<ChangeLogSet.Entry>>) getChangeSets
                            .invoke(run);
                    if (Iterables.all(sets, Predicates.instanceOf(ChangeLogSet.class))) {
                        for (ChangeLogSet<ChangeLogSet.Entry> set : sets) {
                            addChangeSetUsers(set, users, debug);
                        }
                    }
                }
            } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
                debug.send("Exception getting changesets for %s: %s", run, e);
            }
        }
    }
    return users;
}

From source file:com.twitter.common.base.Closures.java

/**
 * Combines multiple closures into a single closure, whose calls are replicated sequentially
 * in the order that they were provided.
 * If an exception is encountered from a closure it propagates to the top-level closure and the
 * remaining closures are not executed.//from   w  ww  . j  ava  2s  .  co  m
 *
 * @param closures Closures to combine.
 * @param <T> Type accepted by the closures.
 * @return A single closure that will fan out all calls to {@link Closure#execute(Object)} to
 *    the wrapped closures.
 */
public static <T> Closure<T> combine(Iterable<Closure<T>> closures) {
    checkNotNull(closures);
    checkArgument(Iterables.all(closures, Predicates.notNull()));

    final Iterable<Closure<T>> closuresCopy = ImmutableList.copyOf(closures);

    return new Closure<T>() {
        @Override
        public void execute(T item) {
            for (Closure<T> closure : closuresCopy) {
                closure.execute(item);
            }
        }
    };
}

From source file:eu.numberfour.n4js.ui.containers.CompositeStorage2UriMapperContribution.java

@Override
public boolean isRejected(final IFolder folder) {
    return Iterables.all(contributions, c -> c.isRejected(folder));
}