public class CollectionFunctionals
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CollectionFunctionals.FirstElementFunction<T> |
static class |
CollectionFunctionals.SizeFunction |
Constructor and Description |
---|
CollectionFunctionals() |
Modifier and Type | Method and Description |
---|---|
static <T,TT extends java.lang.Iterable<T>> |
all(com.google.common.base.Predicate<T> attributeSatisfies)
Returns a predicate for a collection which is true if
all elements in the collection given to the predicate
which satisfies the predicate given here.
|
static <T,TT extends java.lang.Iterable<T>> |
any(com.google.common.base.Predicate<T> attributeSatisfies)
Returns a predicate for a collection which is true if
there is at least one element in the collection given to the predicate
which satisfies the predicate given here.
|
static <I,T extends java.util.Collection<I>> |
contains(I item) |
static com.google.common.base.Predicate<java.lang.Iterable<?>> |
empty() |
static com.google.common.base.Predicate<java.lang.Iterable<?>> |
equalsSet(java.lang.Iterable<?> target) |
static com.google.common.base.Predicate<java.lang.Iterable<?>> |
equalsSetOf(java.lang.Object... target)
default guava Equals predicate will reflect order of target, and will fail when matching against a list;
this treats them both as sets
|
static <T> com.google.common.base.Function<java.lang.Iterable<? extends T>,T> |
firstElement() |
static <K> com.google.common.base.Function<java.util.Map<K,?>,java.util.Set<K>> |
keys() |
static <T,I extends java.lang.Iterable<T>> |
limit(int max) |
static <K> com.google.common.base.Function<java.util.Map<K,?>,java.lang.Integer> |
mapSize() |
static <K> com.google.common.base.Function<java.util.Map<K,?>,java.lang.Integer> |
mapSize(java.lang.Integer valueIfNull) |
static <K> com.google.common.base.Predicate<java.util.Map<K,?>> |
mapSizeEquals(int targetSize) |
static com.google.common.base.Predicate<java.lang.Iterable<?>> |
notEmpty() |
static <T,TT extends java.lang.Iterable<T>> |
quorum(QuorumCheck quorumCheck,
com.google.common.base.Predicate<T> attributeSatisfies)
Returns a predicate for a collection which is true if
the number of elements in the collection satisfying the predicate given here
passes the
QuorumCheck given here. |
static com.google.common.base.Predicate<java.lang.Iterable<?>> |
sizeEquals(int targetSize) |
static com.google.common.base.Function<java.lang.Iterable<?>,java.lang.Integer> |
sizeFunction() |
static com.google.common.base.Function<java.lang.Iterable<?>,java.lang.Integer> |
sizeFunction(java.lang.Integer valueIfInputNull) |
static com.google.common.base.Supplier<java.lang.Integer> |
sizeSupplier(java.lang.Iterable<?> collection) |
public static com.google.common.base.Supplier<java.lang.Integer> sizeSupplier(java.lang.Iterable<?> collection)
public static com.google.common.base.Function<java.lang.Iterable<?>,java.lang.Integer> sizeFunction()
public static com.google.common.base.Function<java.lang.Iterable<?>,java.lang.Integer> sizeFunction(java.lang.Integer valueIfInputNull)
public static <T> com.google.common.base.Function<java.lang.Iterable<? extends T>,T> firstElement()
public static <K> com.google.common.base.Function<java.util.Map<K,?>,java.util.Set<K>> keys()
public static <K> com.google.common.base.Function<java.util.Map<K,?>,java.lang.Integer> mapSize()
public static <K> com.google.common.base.Function<java.util.Map<K,?>,java.lang.Integer> mapSize(java.lang.Integer valueIfNull)
public static com.google.common.base.Predicate<java.lang.Iterable<?>> equalsSetOf(java.lang.Object... target)
public static com.google.common.base.Predicate<java.lang.Iterable<?>> equalsSet(java.lang.Iterable<?> target)
public static com.google.common.base.Predicate<java.lang.Iterable<?>> sizeEquals(int targetSize)
public static com.google.common.base.Predicate<java.lang.Iterable<?>> empty()
public static com.google.common.base.Predicate<java.lang.Iterable<?>> notEmpty()
public static <K> com.google.common.base.Predicate<java.util.Map<K,?>> mapSizeEquals(int targetSize)
public static <T,I extends java.lang.Iterable<T>> com.google.common.base.Function<I,java.util.List<T>> limit(int max)
public static <I,T extends java.util.Collection<I>> com.google.common.base.Predicate<T> contains(I item)
public static <T,TT extends java.lang.Iterable<T>> com.google.common.base.Predicate<TT> all(com.google.common.base.Predicate<T> attributeSatisfies)
This will return true for the empty set.
To require additionally that there is at least one
use quorum(QuorumCheck, Predicate)
with
QuorumCheck.QuorumChecks.allAndAtLeastOne()
.
public static <T,TT extends java.lang.Iterable<T>> com.google.common.base.Predicate<TT> any(com.google.common.base.Predicate<T> attributeSatisfies)
public static <T,TT extends java.lang.Iterable<T>> com.google.common.base.Predicate<TT> quorum(QuorumCheck quorumCheck, com.google.common.base.Predicate<T> attributeSatisfies)
QuorumCheck
given here.