GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.lang
Class GridFunc

java.lang.Object
  extended by org.gridgain.grid.lang.GridFunc
Direct Known Subclasses:
F

public class GridFunc
extends Object

Start Here  Contains factory and utility methods for closures, predicates, and tuples. It also contains functional style collection comprehensions.

Most of the methods in this class can be divided into two groups:

Note that contrary to the usual design this class has substantial number of methods (over 200). This design is chosen to simulate a global namespace (like a Predef in Scala) to provide general utility and functional programming functionality in a shortest syntactical context using F typedef.

Wiki & Forum:


Wiki
Forum

 

Constructor Summary
GridFunc()
           
 
Method Summary
static
<T extends Runnable>
Collection<GridJob>
absJobs(Collection<? extends T> c)
          Converts collection of absolute closures to the read only collection of grid jobs.
static Collection<GridJob> absJobs(Runnable... c)
          Converts array of out closures to the collection of grid jobs.
static
<K,V> V
addIfAbsent(ConcurrentMap<K,V> map, K key, Callable<V> c)
          Gets the value with given key.
static
<K,V> V
addIfAbsent(ConcurrentMap<K,V> map, K key, V val)
          Gets the value with given key.
static
<K,V> V
addIfAbsent(Map<K,V> map, K key, Callable<V> c)
          Utility map getter.
static
<K,V> V
addIfAbsent(Map<K,V> map, K key, V v)
          Utility map getter.
static
<T> GridPredicate<T>
alwaysFalse()
          Gets predicate that always returns false.
static
<T> GridPredicate<T>
alwaysTrue()
          Gets predicate that always returns true.
static
<T> GridPredicate<T>
and(Collection<? extends GridPredicate<? super T>> ps)
          Get a predicate that evaluates to true if each of its component predicates evaluates to true.
static
<T> GridPredicate<T>
and(GridPredicate<? super T>... ps)
          Get a predicate that evaluates to true if each of its component predicates evaluates to true.
static
<T> GridPredicate<T>
and(GridPredicate<? super T>[] p1, GridPredicate<? super T>... p2)
          Get a predicate that evaluates to true if each of its component predicates evaluates to true.
static GridAbsPredicate as(Callable<Boolean> c)
          Converts given closure to predicate.
static
<R> GridOutClosure<R>
as(Callable<R> c)
          Converts given callable to an out-closure.
static
<T> GridOutClosure
as(Future<T> fut)
          Converts given future into the closure.
static GridOutClosure<Boolean> as(GridAbsPredicate p)
          Converts given predicate to closure.
static
<T> GridPredicate<T>
as(GridClosure<? super T,Boolean> c)
          Converts given closure to predicate.
static
<T1,T2> GridPredicate2<T1,T2>
as(GridClosure2<? super T1,? super T2,Boolean> c)
          Converts given closure to predicate.
static
<T1,T2,T3> GridPredicate3<T1,T2,T3>
as(GridClosure3<? super T1,? super T2,? super T3,Boolean> c)
          Converts given closure to predicate.
static
<T> Future<T>
as(GridFuture<T> fut)
          Converts given object with interface GridFuture into an object implementing Future.
static
<X> GridClosure<X,Boolean>
as(GridPredicate<? super X> p)
          Converts given predicate to closure.
static
<X1,X2> GridClosure2<X1,X2,Boolean>
as(GridPredicate2<? super X1,? super X2> p)
          Converts given predicate to closure.
static
<X1,X2,X3> GridClosure3<X1,X2,X3,Boolean>
as(GridPredicate3<? super X1,? super X2,? super X3> p)
          Converts given predicate to closure.
static
<T> GridIterable<T>
as(Iterator<T> iter)
          Converts given iterator into instance of Iterable interface.
static GridAbsClosure as(Runnable r)
          Converts given runnable to an absolute closure.
static
<E1,E2> GridPredicate<GridTuple2<E1,E2>>
as0(GridPredicate2<? super E1,? super E2> p)
          Converts predicate with two separate values to a predicate with tuple.
static
<T> T[]
asArray(T... t)
          Convinience method to convert multiple elements into array.
static
<T> List<T>
asList(T... vals)
          Converts array to List.
static
<T> List<T>
asList(T t)
          Creates read-only list with given values.
static
<K,V> Map<K,V>
asMap(K k, V v)
          Creates map with given values.
static
<K,V> Map<K,V>
asMap(K k1, V v1, K k2, V v2)
          Creates map with given values.
static
<K,V> Map<K,V>
asMap(K k1, V v1, K k2, V v2, K k3, V v3)
          Creates map with given values.
static
<K,V> Map<K,V>
asMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
          Creates map with given values.
static
<K,V> Map<K,V>
asMap(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
          Creates map with given values.
static
<T> Set<T>
asSet(T... t)
          Creates read-only set with given values.
static
<T> Set<T>
asSet(T t)
          Creates read-only set with given value.
static double avg(Iterable<? extends Number> c)
          Calculates arithmetic mean.
static
<T extends Number>
GridReducer<T,Double>
avgReducer()
          Gets reducer closure that calculates arithmetic mean.
static
<T> void
awaitAll(Collection<GridFuture<T>> futs)
          Waits until all passed futures will be executed.
static
<T> void
awaitAll(GridFuture<T>... futs)
          Waits until all passed futures will be executed.
static
<T> void
awaitAll(long timeout, Collection<GridFuture<T>> futs)
          Waits until all passed futures will be executed.
static
<T,R> R
awaitAll(long timeout, GridReducer<T,R> rdc, Collection<GridFuture<T>> futs)
          Awaits for all futures to complete and optionally reduces all results into one.
static
<T> GridFuture<T>
awaitOne(GridFuture<T>... futs)
          Waits for one completed future from passed and returns it.
static
<T> GridFuture<T>
awaitOne(Iterable<GridFuture<T>> futs)
          Waits for the first completed future from passed and returns it.
static
<T> GridPredicate<T>
breaker(boolean firstVal)
          Gets breaker predicate which will return a predicate that will evaluate to firstVal when checked the first time, but then will always evaluate to the opposite value.
static
<T> GridClosure<Callable<T>,GridOutClosure<T>>
c2c()
          Returns closure that converts Callable to GridOutClosure.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheBackup()
          Gets predicate which returns true if GridCacheEntry.primary() method returns false.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsEntriesGet(Collection<? extends Map.Entry<K,V>> entries)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsEntriesGet(Map.Entry<K,V>... entries)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsEntriesPeek(Collection<? extends Map.Entry<K,V>> entries)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsEntriesPeek(Map.Entry<K,V>... entries)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsGet(Collection<? extends V> vals)
          Gets predicate which returns true if GridCacheEntry.get(GridPredicate[]) method returns value that is contained in given collection.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsGet(Map<K,V> map)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsGet(V... vals)
          Gets predicate which returns true if GridCacheEntry.get(GridPredicate[]) method returns value that is contained among given values.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsPeek(Collection<? extends V> vals)
          Gets predicate which returns true if GridCacheEntry.peek(GridPredicate[]) methods returns value that is contained in given collection.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsPeek(Map<K,V> map)
          Gets predicate which returns true if cache entry matches any given key-value pair.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheContainsPeek(V... vals)
          Gets predicate which returns true if GridCacheEntry.peek(GridPredicate[]) methods returns value that is contained among given values.
static
<K,V> GridClosure<GridCacheEntry<K,V>,V>
cacheEntry2Get()
          Gets closure that returns value for an entry.
static
<K,V> GridClosure<GridCacheEntry<K,V>,V>
cacheEntry2Peek()
          Gets closure that returns result of GridCacheStrictProjection.peek() method.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheExpireAfter(long msec)
          Gets predicate which returns true if entry expires on or after given time in milliseconds.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheExpireBefore(long msec)
          Gets predicate which returns true if entry expires on or before given time in milliseconds.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheHasGetValue()
          Gets predicate which returns true if GridCacheEntry.get(GridPredicate[]) method returns non-null value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheHasKeys(Collection<? extends K> keys)
          Gets predicate which returns true if entry's key is contained in given collection.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheHasKeys(K... keys)
          Gets predicate which returns true if entry's key is equal to any of provided keys.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheHasPeekValue()
          Gets predicate which returns true if GridCacheEntry.peek() method returns non-null value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheKeys(GridPredicate<? super K>... ps)
          Converts key filter to entry filter using Map.Entry.getKey() to get value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheMetrics(Collection<? extends GridPredicate<? super GridCacheMetrics>> p)
          Converts metrics filter to entry filter using GridCacheEntry.metrics().
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheMetrics(GridPredicate<? super GridCacheMetrics>... p)
          Converts metrics filter to entry filter using GridCacheEntry.metrics().
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNodeIds(Collection<UUID> nodeIds)
          Gets predicate which returns true if cache entry subgrid is a subset of given nodes (specified by ids).
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNodeIds(UUID... nodeIds)
          Gets predicate which returns true if cache entry subgrid is a subset of given nodes (specified by ids).
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNodes(Collection<? extends GridRichNode> nodes)
          Gets predicate which returns true if cache entry subgrid is a subset of given nodes.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNodes(GridProjection... prj)
          Gets predicate which returns true if cache entry nodes is a subset of given grid projections' nodes.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNodes(GridRichNode... nodes)
          Gets predicate which returns true if cache entry subgrid is a subset of given nodes.
static GridPredicate<GridRichNode> cacheNodesForNames(String... cacheNames)
          Gets node predicate which returns true for all nodes which have given cache names started.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNoGetValue()
          Gets predicate which returns true if GridCacheEntry.get(GridPredicate[]) method returns null value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheNoPeekValue()
          Gets predicate which returns true if GridCacheEntry.peek() method returns null value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cachePrimary()
          Gets predicate which returns true if GridCacheEntry.primary() method returns true.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheValuesGet(GridPredicate<? super V>... ps)
          Converts value filter to entry filter using GridCacheEntry.get(GridPredicate[]) to get value.
static
<K,V> GridPredicate<GridCacheEntry<K,V>>
cacheValuesPeek(GridPredicate<? super V>... ps)
          Converts value filter to entry filter using GridCacheEntry.peek(GridPredicate[]) to get value.
static GridAbsClosure caInvoke(Class<?> cls, String mtdName, Object... args)
          Creates absolute closure that will reflectively call a static method with the given name.
static GridAbsClosure caInvoke(Object o, String mtdName, Object... args)
          Creates absolute closure that will reflectively call a method with the given name on provided object.
static
<T> GridInClosure<T>
ciInvoke(String mtdName, Object... args)
          Creates in closure that will reflectively call a method with the given name on closure's argument.
static
<T,R> GridClosure<T,R>
cInvoke(String mtdName, Object... args)
          Creates closure that will reflectively call a method with the given name on closure's argument and return result of that call.
static GridClosure<Object,Class<?>> clazz()
          Gets closure that converts object to its runtime class.
static
<R> GridOutClosure<R>
coInvoke(Class<?> cls, String mtdName, Object... args)
          Creates out closure that will reflectively call a static method with the given name and return result of that call.
static
<R> GridOutClosure<R>
coInvoke(Object o, String mtdName, Object... args)
          Creates out closure that will reflectively call a method with the given name on provided object and return result of that call.
static
<D,B,C> GridClosure<D,C>
compose(GridClosure<? super D,? extends B> f, GridClosure<? super B,C> g)
          Composes two closures into one.
static
<X,Y> GridPredicate<X>
compose(GridPredicate<? super Y> p, GridClosure<? super X,? extends Y> f)
          Gets a predicate that is composed of given predicate and closure.
static
<T> Collection<T>
concat(boolean copy, Collection<T> c1, Collection<T> c2)
          Concatenates 2 collections into one.
static
<T> Collection<T>
concat(boolean copy, T t, Collection<T> c)
          Concatenates an element to a collection.
static String concat(Iterable<String> c, String delim)
          Concatenates strings using provided delimiter.
static
<T> T[]
concat(T[] arr, T... obj)
          Concatenates an elements to an array.
static GridReducer<String,String> concatReducer(String delim)
          Gets reducer closure that concatenates strings using provided delimiter.
static
<R> GridOutClosure<R>
constant(R val)
          Gets closure that returns constant value.
static
<T1,R> GridClosure<T1,R>
constant1(R val)
          Gets closure that returns constant value.
static
<T1,T2,R> GridClosure2<T1,T2,R>
constant2(R val)
          Gets closure that returns constant value.
static
<T1,T2,T3,R>
GridClosure3<T1,T2,T3,R>
constant3(R val)
          Gets closure that returns constant value.
static
<T> GridPredicate<T>
contains(Collection<T> c)
          Provides predicate which returns true if it receives an element that is contained in the passed in collection.
static
<T> boolean
contains(Collection<T> c, T t)
          Checks if value is contained in the collection passed in.
static
<T> boolean
containsAll(Collection<? extends T> c1, Iterable<? extends T> c2)
          Checks if collection c1 contains all elements from collection c2.
static
<T> boolean
containsAny(Collection<? extends T> c1, Iterable<? extends T> c2)
          Checks if collection c1 contains any elements from collection c2.
static
<T> boolean
containsAny(Collection<? extends T> c1, T... c2)
          Checks if collection c1 contains any elements from array c2.
static
<T,R> GridReducer<T,R>
continuousReducer(R elem)
          Gets reducer which always returns true from GridReducer.collect(Object) method and passed in element from GridOutClosure.apply() method.
static
<T> Collection<T>
copy(Collection<T> to, Iterable<? extends T> from, GridPredicate<? super T>... p)
          Adds (copies) to given collection using provided predicates.
static
<T> Collection<T>
copy(Collection<T> to, T... from)
          Adds (copies) to given collection all elements in 'from' array.
static
<T,R> Collection<GridOutClosure<R>>
curry(Collection<? extends GridClosure<? super T,R>> in, Collection<? extends T> args)
          Curries collection of closures with given collection of arguments.
static
<T,R> Collection<GridOutClosure<R>>
curry(Collection<? extends GridClosure<? super T,R>> iter, T arg)
          Curries collection of closures with given argument.
static
<T,R> Collection<GridOutClosure<R>>
curry(GridClosure<? super T,R> c, Collection<? extends T> args)
          Curries collection of closures with given collection of arguments.
static
<T> Collection<GridAbsClosure>
curry(GridInClosure<? super T> c, Collection<? extends T> args)
          Curries collection of closures with given collection of arguments.
static
<T,R> Collection<GridOutClosure<R>>
curry(int cnt, GridClosure<? super T,R> c, GridOutClosure<T> pdc)
          Curries collection of closures with given collection of arguments.
static
<T> Collection<GridAbsClosure>
curry(int cnt, GridInClosure<? super T> c, GridOutClosure<T> pdc)
          Curries collection of closures with given collection of arguments.
static
<T> Collection<GridAbsClosure>
curry0(Collection<? extends GridInClosure<? super T>> in, Collection<? extends T> args)
          Curries collection of in closures with given collection of arguments.
static
<T1,T2,R> Collection<GridClosure<T2,R>>
curry2(Collection<? extends GridClosure2<? super T1,T2,R>> iter, T1 arg)
          Curries collection of closures with given argument.
static
<T1,T2,T3,R>
Collection<GridClosure2<T2,T3,R>>
curry3(Collection<? extends GridClosure3<? super T1,T2,T3,R>> iter, T1 arg)
          Curries collection of closures with given argument.
static
<T> Collection<T>
dedup(Collection<? extends T> c)
          Creates new collection by removing duplicates from the given collection.
static
<R> GridOpt<R>
doWhile(Callable<R> body, GridAbsPredicate cond)
          Executes given body until provided condition evaluates to true via do-while Java loop (test-after).
static void doWhile(GridAbsClosure body, GridAbsPredicate cond)
          Executes given body until provided condition evaluates to true via do-while Java loop (test-after).
static
<T> Iterable<T>
drop(Iterable<T> c, GridPredicate<? super T>... p)
          Removes elements in-place from given collection.
static
<T> GridIterator<T>
emptyIterator()
          Creates new empty iterator.
static boolean eq(Object o1, Object o2)
          Tests whether specified arguments are equal, or both null.
static boolean eqArray(Object[] a1, Object[] a2, boolean sorted, boolean dups)
          Compares two arrays.
static boolean eqNodes(Object n1, Object n2)
          Compares two GridNode instances for equality.
static boolean eqNotOrdered(Collection<?> c1, Collection<?> c2)
          Checks if both collections have equal elements in any order.
static boolean eqOrdered(Collection<?> c1, Collection<?> c2)
          Checks if both collections have equal elements in the same order.
static
<T> GridPredicate<T>
equalTo(T target)
          Gets predicate that evaluates to true if its free variable is equal to target or both are null.
static GridPredicate<GridEvent> eventAfter(long tstamp)
          Gets event predicate that returns true only if event was produced after given timestamp.
static GridPredicate<GridEvent> eventId(GridUuid... ids)
          Gets event predicate that returns true only if event id is one of the given.
static GridPredicate<GridEvent> eventNode(Collection<? extends GridRichNode> nodes)
          Gets event predicate that returns true only if node that produced the event is one of the given.
static GridPredicate<GridEvent> eventNode(String gridName, GridPredicate<? super GridRichNode>... p)
          Gets event predicate that returns true only if node that produced the event satisfies all given predicates.
static GridPredicate<GridEvent> eventNodeId(UUID... nodeIds)
          Gets event predicate that returns true only if event was produced on one of given nodes (specified by ids).
static GridPredicate<GridEvent> eventType(int... types)
          Gets event predicate that returns true only if event type is one of the given.
static
<V> boolean
exist(Iterable<? extends V> c, GridPredicate<? super V>... p)
          Checks for existence of the element in input collection for which all provided predicates evaluate to true.
static
<K1,K extends K1,V1,V extends V1>
boolean
exist(Map<K,V> m, GridPredicate<? super Map.Entry<K,V>>... p)
          Checks for existence of the entry in input map for which all provided predicates evaluate to true.
static
<V> boolean
exist(V[] c, GridPredicate<? super V>... p)
          Checks for existence of the element in input array for which all provided predicates evaluate to true.
static
<T> GridOutClosure<T>
factory(Class<T> cls)
          Creates and returns new factory closure for the given type.
static
<V> V
find(Iterable<? extends V> c, V dfltVal, GridPredicate<? super V>... p)
          Finds and returns first element in given collection for which any of the provided predicates evaluates to true.
static
<V,Y> Y
find(Iterable<? extends V> c, Y dfltVal, GridClosure<? super V,Y> f, GridPredicate<? super V>... p)
          Finds, transforms and returns first element in given collection for which any of the provided predicates evaluates to true.
static
<V> V
find(V[] c, V dfltVal, GridPredicate<? super V>... p)
          Finds and returns first element in given array for which any of the provided predicates evaluates to true.
static
<V,Y> Y
find(V[] c, Y dfltVal, GridClosure<? super V,Y> f, GridPredicate<? super V>... p)
          Finds, transforms and returns first element in given array for which any of the provided predicates evaluates to true.
static GridPredicate<GridFuture<?>> finishedFutures()
          Returns predicate for filtering finished futures.
static
<T> T
first(Iterable<? extends T> c)
          Gets first element from given collection or returns null if the collection is empty.
static
<K,V> Map.Entry
firstEntry(Map<K,V> m)
          Gets first key from given map or returns null if the map is empty.
static
<K> K
firstKey(Map<K,?> m)
          Gets first key from given map or returns null if the map is empty.
static
<V> V
firstValue(Map<?,V> m)
          Gets first value from given map or returns null if the map is empty.
static
<T> Collection<T>
flat(Collection<? extends Collection<T>> c)
          Flattens collection-of-collections and returns collection over the elements of the inner collections.
static
<T> GridIterator<T>
flat(Iterable<? extends Iterable<T>> c)
          Flattens iterable-of-iterables and returns iterable over the elements of the inner collections.
static Collection<Object> flat0(Object... objs)
          Flattens given set objects into a single collection.
static
<D,B> B
fold(D[] c, B b, GridClosure2<? super D,? super B,B>... fs)
          Folds-right given array using provided closure.
static
<D,B> B
fold(Iterable<? extends D> c, B b, GridClosure2<? super D,? super B,B>... fs)
          Folds-right given collection using provided closure.
static
<V> boolean
forAll(Iterable<? extends V> c, GridPredicate<? super V>... p)
          Applies all given predicates to all elements in given input collection and returns true if all of them evaluate to true for all elements.
static
<K1,K extends K1,V1,V extends V1>
boolean
forAll(Map<K,V> m, GridPredicate<? super Map.Entry<K,V>>... p)
          Applies given predicates to all entries in given input map and returns true if all of them evaluates to true for all entries.
static
<V> boolean
forAll(V[] c, GridPredicate<? super V>... p)
          Applies all given predicates to all elements in given input array and returns true if all of them evaluate to true for all elements.
static
<V> boolean
forAny(Iterable<? extends V> c, GridPredicate<? super V>... p)
          Applies all given predicates to all elements in given input collection and returns true if all predicates evaluate to true for at least one element.
static
<K1,K extends K1,V1,V extends V1>
boolean
forAny(Map<K,V> m, GridPredicate<? super Map.Entry<K,V>>... p)
          Applies given predicates to all entries in given input map and returns true if all of them evaluates to true for at least one entry.
static
<V> boolean
forAny(V[] c, GridPredicate<? super V>... p)
          Applies all given predicates to all elements in given input array and returns true if all of them evaluate to true for at least one element.
static
<X> void
forEach(Iterable<? extends X> c, GridInClosure<? super X> f, GridPredicate<? super X>... p)
          Calls given side-effect only closure over the each element of the provided collection.
static
<K,V> void
forEach(Map<? extends K,? extends V> m, GridInClosure<? super GridTuple2<K,V>> f, GridPredicate<? super GridTuple2<K,V>>... p)
          Calls given side-effect only closure (if provided) over the each element of the provided map.
static
<X> void
forEach(X[] c, GridInClosure<? super X> f, GridPredicate<? super X>... p)
          Calls given side-effect only closure over the each element of the provided array.
static
<K,V> GridClosure<K,V>
forMap(Map<? extends K,? extends V> m)
          Gets closure that wraps given map access, i.e. returns map's value assuming that free variable is a map's key.
static
<K,V> GridClosure<K,V>
forMap(Map<? extends K,? extends V> m, Callable<V> c)
          Gets closure that wraps given map's access, i.e. returns map's value assuming that free variable is a map's key or default value produced by optional factory closure if key has no mapping.
static
<T> GridClosure<GridFuture<T>,Future<T>>
future()
          Gets closure that converts GridFuture to Future.
static double gavg(Iterable<? extends Number> c)
          Calculates geometric mean.
static
<T extends Number>
GridReducer<T,Double>
gavgReducer()
          Gets reducer closure that calculates geometric mean.
static double havg(Iterable<? extends Number> c)
          Calculates harmonic mean.
static
<T extends Number>
GridReducer<T,Double>
havgReducer()
          Gets reducer closure that calculates harmonic mean.
static GridClosure<UUID,String> id2id8()
          Gets closure which converts node ID to node ID8 representation (shorter and good enough).
static Collection<String> id8s(Collection<UUID> ids)
          Convenient utility method that returns collection of node ID8s for a given collection of node IDs.
static
<T> GridClosure<T,T>
identity()
          Gets identity closure, i.e. the closure that returns its variable value.
static
<T> GridReducer<T,T>
identityReducer(T elem)
          Gets reducer which always returns true from GridReducer.collect(Object) method and passed in element from GridOutClosure.apply() method.
static GridPredicate<UUID> idForNodeId(UUID nodeId)
          Creates UUID predicate evaluating on the given node ID.
static GridPredicate<UUID> idForNodeIds(Collection<UUID> nodeIds)
          Creates UUID predicate evaluating on the given node IDs.
static GridPredicate<UUID> idForNodeIds(UUID... nodeIds)
          Creates UUID predicate evaluating on the given node IDs.
static
<T> GridPredicate<T>
in(Collection<? extends T> c)
          Gets predicate that returns true if its free variable is contained in given collection.
static
<T> GridPredicate<T>
in(T[] c)
          Gets predicate that returns true if its free variable is contained in given array.
static
<T> GridPredicate<T>
instanceOf(Class<?> cls)
          Gets predicate that evaluates to true if its free variable is instance of the given class.
static
<E> boolean
intersects(Iterable<E> s1, Collection<E>... s2)
          Checks if two collections passed in intersect.
static
<T> boolean
isAll(T t, GridPredicate<? super T>... p)
          Tests if all provided predicates evaluate to true for given value.
static
<T> boolean
isAll(T t, Iterable<? extends GridPredicate<? super T>> p)
          Tests if all provided predicates evaluate to true for given value.
static
<A,B> boolean
isAll2(A a, B b, GridPredicate2<? super A,? super B> p)
          Tests if all provided predicates evaluate to true for given values.
static
<A,B> boolean
isAll2(A a, B b, GridPredicate2<? super A,? super B>[] p)
          Tests if all provided predicates evaluate to true for given values.
static
<A,B> boolean
isAll2(A a, B b, Iterable<? extends GridPredicate2<? super A,? super B>> p)
          Tests if all provided predicates evaluate to true for given values.
static
<A,B,C> boolean
isAll3(A a, B b, C c, GridPredicate3<? super A,? super B,? super C>... p)
          Tests if all provided predicates evaluate to true for given values.
static
<A,B,C> boolean
isAll3(A a, B b, C c, Iterable<? extends GridPredicate3<? super A,? super B,? super C>> p)
          Tests if all provided predicates evaluate to true for given values.
static boolean isAlwaysFalse(GridPredicate p)
          Tests whether or not given predicate is the one returned from GridFunc.alwaysFalse() method.
static boolean isAlwaysFalse(GridPredicate[] p)
          Tests whether or not given set of predicates consists only of one predicate returned from GridFunc.alwaysFalse() method.
static boolean isAlwaysTrue(GridPredicate p)
          Tests whether or not given predicate is the one returned from GridFunc.alwaysTrue() method.
static boolean isAlwaysTrue(GridPredicate[] p)
          Tests whether or not given set of predicates consists only of one predicate returned from GridFunc.alwaysTrue() method.
static
<T> boolean
isAny(T t, GridPredicate<? super T>... p)
          Tests if any of provided predicates evaluate to true for given value.
static
<T> boolean
isAny(T t, Iterable<? extends GridPredicate<? super T>> p)
          Tests if any of provided predicates evaluate to true for given value.
static
<A,B> boolean
isAny2(A a, B b, GridPredicate2<? super A,? super B>... p)
          Tests if any of provided predicates evaluate to true for given values.
static
<A,B> boolean
isAny2(A a, B b, Iterable<? extends GridPredicate2<? super A,? super B>> p)
          Tests if any of provided predicates evaluate to true for given values.
static
<A,B,C> boolean
isAny3(A a, B b, C c, GridPredicate3<? super A,? super B,? super C>... p)
          Tests if any of provided predicates evaluate to true for given values.
static
<A,B,C> boolean
isAny3(A a, B b, C c, Iterable<? extends GridPredicate3<? super A,? super B,? super C>> p)
          Tests if any of provided predicates evaluate to true for given values.
static boolean isEmpty(Collection<?> c)
          Tests if the given collection is either null or empty.
static boolean isEmpty(int[] c)
          Tests if the given array is either null or empty.
static boolean isEmpty(Iterable<?> c)
          Tests if the given collection is either null or empty.
static boolean isEmpty(Map<?,?> m)
          Tests if the given map is either null or empty.
static boolean isEmpty(String s)
          Tests if given string is null or empty.
static
<T> boolean
isEmpty(T[] c)
          Tests if the given array is either null or empty.
static
<T> GridPredicate<T>
isNull()
          Gets predicate that evaluates to true if its free variable is null.
static
<T> GridIterable<T>
iterable(Collection<? extends T> c, GridPredicate<? super T>... p)
          Creates and returns iterable from given collection and optional filtering predicates.
static
<T1,T2> GridIterator<T2>
iterator(Collection<? extends T1> c, GridClosure<? super T1,T2> trans, boolean readOnly, GridPredicate<? super T1>... p)
          Creates and returns transforming iterator from given collection and optional filtering predicates.
static
<T> GridIterator<T>
iterator0(Collection<? extends T> c, boolean readOnly, GridPredicate<? super T>... p)
          Creates and returns iterator from given collection and optional filtering predicates.
static GridTuple2<String,Object> jexl(String var, Object val)
          Special version of GridFunc.t(Object, Object) method that is tailored for with(...) method in JEXL-based predicates to set up the external context for JEXL evaluation.
static GridJob job(Callable<?> c)
          Converts given closure to a grid job.
static GridJob job(Runnable r)
          Converts given closure to a grid job.
static GridOutClosure<GridJob> jobProducer(GridJob[] c, boolean cyclic)
          Gets closure that wraps access to the given collection of GridJob instances.
static GridOutClosure<GridJob> jobProducer(Iterable<? extends GridJob> jobs, boolean cyclic)
          Gets closure that wraps access to the given collection of GridJob instances.
static
<T> Collection<T>
jobResults(Collection<? extends GridJobResult> res)
          Gets collections of data items from grid job res casted to specified type.
static
<T> T
last(Iterable<? extends T> c)
          Gets last element from given collection or returns null if the collection is empty.
static GridAbsPredicate limit(int n)
          Gets absolute (no-arg) predicate that returns true first n-times it's called - and false thereafter.
static
<T extends GridNode>
GridPredicate<T>
localNode(UUID localNodeId)
          Gets predicate that evaluates to true only for given local node ID.
static
<T> Collection<T>
lose(Collection<? extends T> c, boolean copy, int num)
          Loses up to first num elements of the input collection.
static
<T0,T extends T0>
Collection<T>
lose(Collection<T> c, boolean copy, Collection<T0> filter)
          Loses all elements in input collection that are contained in filter collection.
static
<T> Collection<T>
lose(Collection<T> c, boolean copy, GridPredicate<? super T>... p)
          Loses all elements in input collection that are evaluated to true by all given predicates.
static
<K,V> Map<K,V>
lose(Map<K,V> m, boolean copy, GridPredicate<? super Map.Entry<K,V>>... p)
          Loses all entries in input map that are evaluated to true by all given predicates.
static
<K,V> Map<K,V>
loseKeys(Map<K,V> m, boolean copy, GridPredicate<? super K>... p)
          Loses all entries in input map which keys are evaluated to true by all given predicates.
static
<T> List<T>
loseList(List<T> c, boolean copy, Collection<? super T> filter)
          Loses all elements in input list that are contained in filter collection.
static
<T> Set<T>
loseSet(Set<T> c, boolean copy, Collection<? super T> filter)
          Loses all elements in input set that are contained in filter collection.
static
<K,V> Map<K,V>
loseValues(Map<K,V> m, boolean copy, GridPredicate<? super V>... p)
          Loses all entries in input map which values are evaluated to true by all given predicates.
static
<K> GridClosure<Map.Entry<K,?>,K>
mapEntry2Key()
          Gets closure that returns key for an entry.
static
<V> GridClosure<Map.Entry<?,V>,V>
mapEntry2Value()
          Gets closure that returns value for an entry.
static
<K,V> GridPredicate<Map.Entry<K,V>>
mapKey(K key)
          Gets utility predicate that accepts Map.Entry value and compares its key to the given value.
static
<K,V> GridPredicate<Map.Entry<K,V>>
mapValue(V val)
          Gets utility predicate that accepts Map.Entry value and compares its value to the given value.
static
<T> Collection<T>
meta(Collection<? extends GridMetadataAware> objs, String name)
          Convenient utility method that returns collections of metadata values for a given collection of metadata aware objects.
static
<T extends GridMetadataAware>
GridPredicate<T>
meta(Iterable<String> names)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).
static
<T extends GridMetadataAware>
GridPredicate<T>
meta(Map<String,?> meta)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
static
<T extends GridMetadataAware>
GridPredicate<T>
meta(String... names)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).
static
<T extends GridMetadataAware>
GridPredicate<T>
meta(String name, Object val)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata.
static
<T extends GridMetadataAware>
GridPredicate<T>
metaEntry(Collection<? extends Map.Entry<String,?>> meta)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
static
<T extends GridMetadataAware>
GridPredicate<T>
metaEntry(Map.Entry<String,?>... meta)
          Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
static GridOutClosure<AtomicBoolean> newAtomicBoolean()
          Returns a factory closure that creates new AtomicBoolean instance initialized to false.
static GridOutClosure<AtomicInteger> newAtomicInt()
          Returns a factory closure that creates new AtomicInteger instance initialized to zero.
static GridOutClosure<AtomicLong> newAtomicLong()
          Returns a factory closure that creates new AtomicLong instance initialized to zero.
static
<T> GridOutClosure<AtomicReference<T>>
newAtomicRef()
          Returns a factory closure that creates new AtomicReference instance initialized to null.
static
<K,V> GridOutClosure<ConcurrentMap<K,V>>
newCMap()
          Returns a factory closure that creates new ConcurrentMap instance.
static
<E> GridOutClosure<Set<E>>
newCSet()
          Returns a factory closure that creates new GridConcurrentHashSet instance.
static
<T> GridOutClosure<LinkedList<T>>
newLinkedList()
          Returns a factory closure that creates new LinkedList instance.
static
<T> GridOutClosure<List<T>>
newList()
          Returns a factory closure that creates new List instance.
static
<K,V> GridOutClosure<Map<K,V>>
newMap()
          Returns a factory closure that creates new Map instance.
static
<T> GridOutClosure<Set<T>>
newSet()
          Returns a factory closure that creates new Set instance.
static
<T> GridOutClosure<T>
nill()
          Returns out closure that always returns null.
static GridClosure<GridNode,UUID> node2id()
          Gets closure which converts node to node ID.
static GridClosure<GridNode,String> node2id8()
          Gets closure which converts node to node ID8 representation (shorter and good enough).
static
<T> Collection<T>
nodeAttributes(Collection<? extends GridNode> nodes, String attr)
          Convenient utility method that returns collection of node attributes for a given collection of grid nodes.
static
<T extends GridNode>
GridPredicate<T>
nodeForNodeId(UUID nodeId)
          Creates grid node predicate evaluating on the given node ID.
static
<T extends GridNode>
GridPredicate<T>
nodeForNodeIds(Collection<UUID> nodeIds)
          Creates grid node predicate evaluating on the given node IDs.
static
<T extends GridNode>
GridPredicate<T>
nodeForNodeIds(UUID... nodeIds)
          Creates grid node predicate evaluating on the given node IDs.
static GridPredicate<GridRichNode> nodeForNodes(Collection<? extends GridNode> nodes)
          Creates predicates that evaluates to true for each node in given collection.
static GridPredicate<GridRichNode> nodeForNodes(GridRichNode... nodes)
          Creates predicates that evaluates to true for each node in given collection.
static Collection<String> nodeId8s(Collection<? extends GridNode> nodes)
          Convenient utility method that returns collection of node ID8s for a given collection of grid nodes.
static Collection<UUID> nodeIds(Collection<? extends GridNode> nodes)
          Convenient utility method that returns collection of node IDs for a given collection of grid nodes.
static GridAbsClosure noop()
          Creates an absolute (no-arg) closure that does nothing.
static
<T> GridPredicate<T>
not(GridPredicate<? super T>... p)
          Negates given predicates.
static
<T> GridPredicate<T>
notContains(Collection<T> c)
          Provides predicate which returns true if it receives an element that is not contained in the passed in collection.
static
<T> GridPredicate<T>
notEqualTo(T target)
          Gets predicate that evaluates to true if its free variable is not equal to target or both are null.
static
<T> GridPredicate<T>
notIn(Collection<? extends T> c)
          Gets predicate that returns true if its free variable is not contained in given collection.
static
<T> GridPredicate<T>
notIn(T[] c)
          Gets predicate that returns true if its free variable is not contained in given array.
static
<T> GridPredicate<T>
notInstanceOf(Class<?> cls)
          Gets predicate that evaluates to true if its free variable is not an instance of the given class.
static
<T> GridPredicate<T>
notNull()
          Gets predicate that evaluates to true if its free variable is not null.
static
<T,R> GridOutClosure<R>
opt(GridOpt<T> opt, GridClosure<T,R> c, R dfltVal)
          Converts given option and closure into output closure that does nothing and returns default value if option is a none value, or applies input closure and returns its value if option is some value.
static
<T> GridAbsClosure
opt(GridOpt<T> opt, GridInClosure<? super T> c)
          Converts given option and closure into absolute closure that does nothing if option is a none value, or applies in closure if option is some value.
static
<T> GridPredicate<T>
or(Collection<? extends GridPredicate<? super T>> ps)
          Get a predicate that evaluates to true if any of its component predicates evaluates to true.
static
<D,B> GridPredicate2<D,B>
or(GridPredicate<? super D> pa, GridPredicate<? super B> pb)
          Gets OR-composition predicate out of two provided predicates.
static
<T> GridPredicate<T>
or(GridPredicate<? super T>... ps)
          Get a predicate that evaluates to true if any of its component predicates evaluates to true.
static
<T> GridPredicate<T>
or(GridPredicate<? super T>[] p1, GridPredicate<? super T>... p2)
          Get a predicate that evaluates to true if any of its component predicates evaluates to true.
static Collection<GridJob> outJobs(Callable<?>... c)
          Converts array of out closures to the collection of grid jobs.
static
<T extends Callable<?>>
Collection<GridJob>
outJobs(Collection<? extends T> c)
          Converts collection of out closures to the read only collection of grid jobs.
static
<T> GridPair<T>
pair(T t1, T t2)
          Creates pair out of given two objects.
static
<V> GridTuple2<Collection<V>,Collection<V>>
partition(Iterable<? extends V> c, GridPredicate<? super V> p)
          Partitions input collection in two: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.
static
<K,V> GridTuple2<Map<K,V>,Map<K,V>>
partition(Map<? extends K,? extends V> m, GridPredicate2<? super K,? super V> p)
          Partitions input map in two: first containing entries for which given predicate evaluates to true - and second containing the entries for which predicate evaluates to false.
static
<V> GridTuple2<Collection<V>,Collection<V>>
partition(V[] c, GridPredicate<? super V> p)
          Partitions input array in two: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.
static GridClosure<GridProjection,GridPredicate<GridRichNode>> predicate()
          Gets closure that transform a grid projection into its predicate.
static
<T> GridInClosure<T>
print()
          Gets closure that prints out its bound variable
static GridAbsClosure print(String msg)
          Creates absolute closure that does System.out.print(msg).
static
<T> GridInClosure<T>
print(String pre, String post)
          Gets closure that prints out its bound variable.
static
<T> GridInClosure<T>
printf(String fmt)
          Gets closure that prints out its bound variable.
static
<T> GridInClosure<T>
println()
          Gets closure that calls System.out.println() on its bound variable.
static GridAbsClosure println(String msg)
          Creates absolute closure that does System.out.println(msg).
static
<T> GridInClosure<T>
println(String pre, String post)
          Gets closure that prints out its bound variable.
static
<T> GridOutClosure<T>
producer(Iterable<? extends T> c, boolean cyclic)
          Gets closure that wraps access to the given collection.
static
<T> GridOutClosure<T>
producer(T[] c, boolean cyclic)
          Gets closure that wraps access to the given collection.
static double qavg(Iterable<? extends Number> c)
          Calculates quadratic mean.
static
<T extends Number>
GridReducer<T,Double>
qavgReducer()
          Gets reducer closure that calculates quadratic mean.
static GridClosure<Runnable,GridAbsClosure> r2c()
          Returns closure that converts Runnable to GridAbsClosure.
static
<T> T
rand(Collection<? extends T> c)
          Gets random value from given collection.
static
<T> T
rand(List<T> l)
          Gets random value from given list.
static
<T> T
rand(T... c)
          Gets random value from given array.
static List<Integer> range(int fromIncl, int toExcl)
          Creates a range list containing numbers in given range.
static
<X,Y> Y
reduce(Iterable<? extends X> c, GridReducer<? super X,Y> f)
          Reduces collection into single value using given for-all closure.
static
<X,Y,R> R
reduce(Map<? extends X,? extends Y> m, GridReducer2<? super X,? super Y,R> f)
          Reduces given map into single value using given for-all closure.
static
<T extends GridNode>
GridPredicate<T>
remoteNodes(UUID locNodeId)
          Gets predicate that evaluates to false for given local node ID.
static
<T0,T extends T0>
Collection<T>
retain(Collection<T> c, boolean copy, Collection<? extends T0> filter)
          Retains all elements in input collection that are contained in filter.
static
<T> Collection<T>
retain(Collection<T> c, boolean copy, GridPredicate<? super T>... p)
          Retains all elements in input collection that are evaluated to true by all given predicates.
static
<T> Collection<T>
retain(Collection<T> c, boolean copy, int num)
          Retains only up to first num elements in the input collection.
static
<K,V> Map<K,V>
retain(Map<K,V> m, boolean copy, GridPredicate<? super Map.Entry<K,V>>... p)
          For a given map retains all map entries that satisfy all provided predicates.
static
<K,V> Map<K,V>
retainKeys(Map<K,V> m, boolean copy, GridPredicate<? super K>... p)
          For a given map retains all map entries which keys satisfy all provided predicates.
static
<K,V> Map<K,V>
retainValues(Map<K,V> m, boolean copy, GridPredicate<? super V>... p)
          For a given map retains all map entries which values satisfy all provided predicates.
static
<K,V> V
returnIfAbsent(Map<? extends K,? extends V> map, K key, Callable<V> c)
          Utility map getter.
static
<T> GridReducer<T,T>
singleReducer()
          Gets reducer closure that collects only a single value and returns it without any transformations.
static
<T> int
size(Collection<? extends T> c, GridPredicate<? super T>... p)
          Gets size of the given collection with provided optional predicates.
static
<T> int
size(Iterator<? extends T> it, GridPredicate<? super T>... p)
          Gets size of the given iterator with provided optional predicates.
static
<T> int
size(T[] c, GridPredicate<? super T>... p)
          Gets size of the given array with provided optional predicates.
static
<T0,T extends T0>
GridPair<Collection<T>>
split(Collection<T> c, GridPredicate<? super T>... p)
          Splits given collection in two using provided set of predicates.
static
<T> GridClosure<T,String>
string()
          Gets closure that return toString() value for its free variable.
static BigDecimal sum(Iterable<BigDecimal> c)
          Calculates sum of all elements.
static BigInteger sum(Iterable<BigInteger> c)
          Calculates sum of all elements.
static double sum(Iterable<Double> c)
          Calculates sum of all elements.
static int sum(Iterable<Integer> c)
          Calculates sum of all elements.
static GridReducer<BigDecimal,BigDecimal> sumBigDecimalReducer()
          Gets reducer closure that calculates sum of all elements.
static GridReducer<BigInteger,BigInteger> sumBigIntegerReducer()
          Gets reducer closure that calculates sum of all elements.
static GridReducer<Double,Double> sumDoubleReducer()
          Gets reducer closure that calculates sum of all elements.
static GridReducer<Integer,Integer> sumIntReducer()
          Gets reducer closure that calculates sum of elements.
static
<V> GridTuple<V>
t(V v)
          Factory method returning new tuple with given parameter.
static
<V1,V2> GridTuple2<V1,V2>
t(V1 v1, V2 v2)
          Factory method returning new tuple with given parameters.
static
<V1,V2,V3> GridTuple3<V1,V2,V3>
t(V1 v1, V2 v2, V3 v3)
          Factory method returning new tuple with given parameters.
static
<V1,V2,V3,V4>
GridTuple4<V1,V2,V3,V4>
t(V1 v1, V2 v2, V3 v3, V4 v4)
          Factory method returning new tuple with given parameters.
static
<V1,V2,V3,V4,V5>
GridTuple5<V1,V2,V3,V4,V5>
t(V1 v1, V2 v2, V3 v3, V4 v4, V5 v5)
          Factory method returning new tuple with given parameters.
static
<V> GridTuple<V>
t1()
          Factory method returning empty tuple.
static
<V1,V2> GridTuple2<V1,V2>
t2()
          Factory method returning new empty tuple.
static
<V1,V2,V3> GridTuple3<V1,V2,V3>
t3()
          Factory method returning new empty tuple.
static
<V1,V2,V3,V4>
GridTuple4<V1,V2,V3,V4>
t4()
          Factory method returning new empty tuple.
static
<V1,V2,V3,V4,V5>
GridTuple5<V1,V2,V3,V4,V5>
t5()
          Factory method returning new empty tuple.
static
<X,Y> Collection<Y>
transform(Collection<? extends X> c, GridClosure<? super X,Y> f)
          Transforms one collection to another using provided closure.
static
<X,Y> Collection<Y>
transform(Collection<? extends X> c, GridClosure<? super X,Y> f, GridPredicate<? super X>... p)
          Transforms one collection to another using provided closure and optional set of predicates.
static
<X,Y> Collection<Y>
transform(Collection<Y> to, Iterable<? extends X> from, GridClosure<? super X,Y> f, GridPredicate<? super X>... p)
          Transforms one collection to another using provided closure and predicate.
static
<X,Y> Collection<Y>
transform(X[] c, GridClosure<? super X,Y> f)
          Transforms an array to read only collection using provided closure.
static
<T1,T2> List<T2>
transformList(Collection<? extends T1> c, GridClosure<? super T1,T2> trans, GridPredicate<? super T1>... p)
          Creates a view on given list with provided transformer and predicates.
static
<T1,T2> Set<T2>
transformSet(Collection<? extends T1> c, GridClosure<? super T1,T2> trans, GridPredicate<? super T1>... p)
          Creates a view on given set with provided transformer and predicates.
static
<T> GridTriple<T>
triple(T t1, T t2, T t3)
          Creates triple out of given three objects.
static GridTupleV tv(Object... objs)
          Creates vararg tuple with given values.
static GridPredicate<GridFuture<?>> unfinishedFutures()
          Returns predicate for filtering unfinished futures.
static
<X,Y extends X>
Collection<Y>
upcast(Collection<? extends X> c, GridClosure<? super X,Y> f)
          Special version of transform method that works on two types that are in child-parent relationship.
static
<T> Collection<T>
view(Collection<T> c, GridPredicate<? super T>... p)
          Creates write-through light-weight view on given collection with provided predicates.
static
<K0,K extends K0,V0,V extends V0>
Map<K,V>
view(Map<K,V> m, GridPredicate<? super K>... p)
          Creates light-weight view on given map with provided predicates.
static
<T1,T2> List<T2>
viewListReadOnly(List<? extends T1> c, GridClosure<? super T1,T2> trans)
          Creates read-only light-weight view on given list with provided transformation.
static
<T1,T2> Collection<T2>
viewReadOnly(Collection<? extends T1> c, GridClosure<? super T1,T2> trans, GridPredicate<? super T1>... p)
          Creates read-only light-weight view on given collection with transformation and provided predicates.
static
<K0,K extends K0,V0,V extends V0,V1>
Map<K,V1>
viewReadOnly(Map<K,V> m, GridClosure<V,V1> trans, GridPredicate<? super K>... p)
          Read-only view on map that supports transformation of values and key filtering.
static double wavg(Collection<? extends Number> c, Collection<? extends Number> w)
          Calculates weighted mean.
static
<R> GridOpt<R>
whileDo(Callable<R> body, GridAbsPredicate cond)
          Executes given body until provided condition evaluates to true via while-do Java loop (test-before).
static void whileDo(GridAbsClosure body, GridAbsPredicate cond)
          Executes given body until provided condition evaluates to true via while-do Java loop (test-before).
static GridClosureException wrap(Throwable e)
          Shortcut method that creates an instance of GridClosureException.
static
<T> GridJexlPredicate<T>
x1(String expr)
          Utility shortcut for creating JEXL predicate.
static
<T> GridJexlPredicate<T>
x1(String expr, String var)
          Utility shortcut for creating JEXL predicate.
static
<T1,T2> GridJexlPredicate2<T1,T2>
x2(String expr)
          Utility shortcut for creating JEXL predicate.
static
<T1,T2> GridJexlPredicate2<T1,T2>
x2(String expr, String var1, String var2)
          Utility shortcut for creating JEXL predicate.
static
<T1,T2,T3> GridJexlPredicate3<T1,T2,T3>
x3(String expr)
          Utility shortcut for creating JEXL predicate.
static
<T1,T2,T3> GridJexlPredicate3<T1,T2,T3>
x3(String expr, String var1, String var2, String var3)
          Utility shortcut for creating JEXL predicate.
static
<T,R> Collection<GridOutClosure<R>>
yield(Collection<? extends T> c, GridClosure<? super T,R> f)
          Given collection of items and a closure this method returns read only collection of closures where each closure is closed on an element of the initial collection.
static
<T> Collection<GridAbsClosure>
yield(Collection<? extends T> c, GridInClosure<? super T> f)
          Given collection of items and a closure this method returns read-only collection of closures where each closure is closed on an element of the initial collection.
static
<T,R> Collection<GridOutClosure<R>>
yield(T[] c, GridClosure<? super T,R> f)
          Given array of items and a closure this method returns collection of closures where each closure is closed on a element of the array.
static
<T> Collection<GridAbsClosure>
yield(T[] c, GridInClosure<? super T> f)
          Given collection of items and a closure this method returns collection of closures where each closure is closed on an element of the initial collection.
static
<K,V> Map<K,V>
zip(Collection<? extends K> keys, Collection<? extends V> vals)
          Converts 2 collections into map using first collection as keys and second collection as values.
static
<K,V> Map<K,V>
zip(Collection<? extends K> keys, V dfltVal)
          Converts collection to map using collection values as keys and passed in default value as values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridFunc

public GridFunc()
Method Detail

breaker

public static <T> GridPredicate<T> breaker(boolean firstVal)
Gets breaker predicate which will return a predicate that will evaluate to firstVal when checked the first time, but then will always evaluate to the opposite value.

Type Parameters:
T - Predicate type.
Parameters:
firstVal - First value.
Returns:
Breaker predicate.

predicate

public static GridClosure<GridProjection,GridPredicate<GridRichNode>> predicate()
Gets closure that transform a grid projection into its predicate.

Returns:
Closure transforming a grid projection into its predicate.

localNode

public static <T extends GridNode> GridPredicate<T> localNode(UUID localNodeId)
Gets predicate that evaluates to true only for given local node ID.

Type Parameters:
T - Type of the node.
Parameters:
localNodeId - Local node ID.
Returns:
Return true only for the node with given local node ID.

remoteNodes

public static <T extends GridNode> GridPredicate<T> remoteNodes(UUID locNodeId)
Gets predicate that evaluates to false for given local node ID.

Type Parameters:
T - Type of the node.
Parameters:
locNodeId - Local node ID.
Returns:
Return false for the given local node ID.

nill

public static <T> GridOutClosure<T> nill()
Returns out closure that always returns null.

Returns:
Out closure that always returns null.

cInvoke

public static <T,R> GridClosure<T,R> cInvoke(String mtdName,
                                             Object... args)
Creates closure that will reflectively call a method with the given name on closure's argument and return result of that call.

Method reflects the typedef for GridClosure which is C1.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Type Parameters:
R - Type of closure return value.
T - Type of closure argument.
Parameters:
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective closure.

ciInvoke

public static <T> GridInClosure<T> ciInvoke(String mtdName,
                                            Object... args)
Creates in closure that will reflectively call a method with the given name on closure's argument.

Method reflects the typedef for GridClosure which is C1.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Type Parameters:
T - Type of closure argument.
Parameters:
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective in closure.

coInvoke

public static <R> GridOutClosure<R> coInvoke(Object o,
                                             String mtdName,
                                             Object... args)
Creates out closure that will reflectively call a method with the given name on provided object and return result of that call.

Method reflects the typedef for GridOutClosure which is CO.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Type Parameters:
R - Type of closure return value.
Parameters:
o - Target object to call the method on.
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective out closure.

caInvoke

public static GridAbsClosure caInvoke(Object o,
                                      String mtdName,
                                      @Nullable
                                      Object... args)
Creates absolute closure that will reflectively call a method with the given name on provided object.

Method reflects the typedef for GridAbsClosure which is CA.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Parameters:
o - Target object to call the method on.
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective absolute closure.

coInvoke

public static <R> GridOutClosure<R> coInvoke(Class<?> cls,
                                             String mtdName,
                                             @Nullable
                                             Object... args)
Creates out closure that will reflectively call a static method with the given name and return result of that call.

Method reflects the typedef for GridOutClosure which is CO.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Type Parameters:
R - Type of closure return value.
Parameters:
cls - Class to call a static method on.
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective out closure.

caInvoke

public static GridAbsClosure caInvoke(Class<?> cls,
                                      String mtdName,
                                      @Nullable
                                      Object... args)
Creates absolute closure that will reflectively call a static method with the given name.

Method reflects the typedef for GridAbsClosure which is CA.

Throws:
GridClosureException - Thrown in case of any reflective invocation errors.
Parameters:
cls - Class to call a static method on.
mtdName - Method name.
args - Optional set of arguments for the method call.
Returns:
Reflective absolute closure.

clazz

public static GridClosure<Object,Class<?>> clazz()
Gets closure that converts object to its runtime class.

Returns:
Closure that converts object to its runtime class.

dedup

public static <T> Collection<T> dedup(Collection<? extends T> c)
Creates new collection by removing duplicates from the given collection.

Type Parameters:
T - Type of the collection.
Parameters:
c - Collection to remove duplicates from.
Returns:
De-duped collection.

sum

public static int sum(Iterable<Integer> c)
Calculates sum of all elements.

Parameters:
c - Collection of elements.
Returns:
Sum of all elements.

sum

public static double sum(Iterable<Double> c)
Calculates sum of all elements.

Parameters:
c - Collection of elements.
Returns:
Sum of all elements.

sum

public static BigDecimal sum(Iterable<BigDecimal> c)
Calculates sum of all elements.

Parameters:
c - Collection of elements.
Returns:
Sum of all elements.

sum

public static BigInteger sum(Iterable<BigInteger> c)
Calculates sum of all elements.

Parameters:
c - Collection of elements.
Returns:
Sum of all elements.

avg

public static double avg(Iterable<? extends Number> c)
Calculates arithmetic mean.

Parameters:
c - Input collection.
Returns:
Arithmetic mean of the input collection.

avgReducer

public static <T extends Number> GridReducer<T,Double> avgReducer()
Gets reducer closure that calculates arithmetic mean.

Returns:
Reducer closure that calculated arithmetic mean.

qavg

public static double qavg(Iterable<? extends Number> c)
Calculates quadratic mean.

Parameters:
c - Input collection.
Returns:
Quadratic mean of the input collection.

qavgReducer

public static <T extends Number> GridReducer<T,Double> qavgReducer()
Gets reducer closure that calculates quadratic mean.

Returns:
Reducer closure that calculated quadratic mean.

gavg

public static double gavg(Iterable<? extends Number> c)
Calculates geometric mean.

Parameters:
c - Input collection.
Returns:
Geometric mean of the input collection.

gavgReducer

public static <T extends Number> GridReducer<T,Double> gavgReducer()
Gets reducer closure that calculates geometric mean.

Returns:
Reducer closure that calculated geometric mean.

wavg

public static double wavg(Collection<? extends Number> c,
                          Collection<? extends Number> w)
Calculates weighted mean.

Parameters:
c - Collection of elements.
w - Collection of weights.
Returns:
Weighted mean of the input collection.

havg

public static double havg(Iterable<? extends Number> c)
Calculates harmonic mean.

Parameters:
c - Input collection.
Returns:
Harmonic mean of the input collection.

singleReducer

public static <T> GridReducer<T,T> singleReducer()
Gets reducer closure that collects only a single value and returns it without any transformations.

Returns:
Reducer closure that collects and returns single value.

continuousReducer

public static <T,R> GridReducer<T,R> continuousReducer(R elem)
Gets reducer which always returns true from GridReducer.collect(Object) method and passed in element from GridOutClosure.apply() method.

Type Parameters:
T - Reducer element type.
R - Return element type.
Parameters:
elem - Element to return from GridOutClosure.apply() method.
Returns:
Passed in element.

identityReducer

public static <T> GridReducer<T,T> identityReducer(T elem)
Gets reducer which always returns true from GridReducer.collect(Object) method and passed in element from GridOutClosure.apply() method.

Type Parameters:
T - Reducer element type.
Parameters:
elem - Element to return from GridOutClosure.apply() method.
Returns:
Passed in element.

havgReducer

public static <T extends Number> GridReducer<T,Double> havgReducer()
Gets reducer closure that calculates harmonic mean.

Returns:
Reducer closure that calculated harmonic mean.

sumIntReducer

public static GridReducer<Integer,Integer> sumIntReducer()
Gets reducer closure that calculates sum of elements.

Returns:
Reducer that calculates sum of elements.

sumDoubleReducer

public static GridReducer<Double,Double> sumDoubleReducer()
Gets reducer closure that calculates sum of all elements.

Returns:
Reducer that calculates sum of all elements.

range

public static List<Integer> range(int fromIncl,
                                  int toExcl)
Creates a range list containing numbers in given range.

Parameters:
fromIncl - Inclusive start of the range.
toExcl - Exclusive stop of the range.
Returns:
List containing numbers in range.

sumBigDecimalReducer

public static GridReducer<BigDecimal,BigDecimal> sumBigDecimalReducer()
Gets reducer closure that calculates sum of all elements.

Returns:
Reducer that calculates sum of all elements.

sumBigIntegerReducer

public static GridReducer<BigInteger,BigInteger> sumBigIntegerReducer()
Gets reducer closure that calculates sum of all elements.

Returns:
Reducer that calculates sum of all elements.

concatReducer

public static GridReducer<String,String> concatReducer(@Nullable
                                                       String delim)
Gets reducer closure that concatenates strings using provided delimiter.

Parameters:
delim - Delimiter (optional).
Returns:
Reducer that concatenates strings using provided delimeter.

concat

public static String concat(Iterable<String> c,
                            @Nullable
                            String delim)
Concatenates strings using provided delimiter.

Parameters:
c - Input collection.
delim - Delimiter (optional).
Returns:
Concatenated string.

jobResults

public static <T> Collection<T> jobResults(@Nullable
                                           Collection<? extends GridJobResult> res)
Gets collections of data items from grid job res casted to specified type.

Here's the typical example of how this method is used in reduce() method implementation (this example sums up all the values of Integer type):

 public Integer reduce(List<GridJobResult> res) throws GridException {
     return F.sum(F.<Integer>jobResults(res));
 }
 

Note that this method doesn't create a new collection but simply iterates over the input one.

Type Parameters:
T - Type of the data item to cast to. See GridJobResult.getData() method.
Parameters:
res - Collection of grid job res.
Returns:
Collections of data items casted to type T.
See Also:
GridJobResult.getData()

nodeIds

public static Collection<UUID> nodeIds(@Nullable
                                       Collection<? extends GridNode> nodes)
Convenient utility method that returns collection of node IDs for a given collection of grid nodes.

Note that this method doesn't create a new collection but simply iterates over the input one.

Parameters:
nodes - Collection of grid nodes.
Returns:
Collection of node IDs for given collection of grid nodes.

nodeId8s

public static Collection<String> nodeId8s(@Nullable
                                          Collection<? extends GridNode> nodes)
Convenient utility method that returns collection of node ID8s for a given collection of grid nodes. ID8 is a shorter string representation of node ID, mainly the first 8 characters.

Note that this method doesn't create a new collection but simply iterates over the input one.

Parameters:
nodes - Collection of grid nodes.
Returns:
Collection of node IDs for given collection of grid nodes.

id8s

public static Collection<String> id8s(@Nullable
                                      Collection<UUID> ids)
Convenient utility method that returns collection of node ID8s for a given collection of node IDs. ID8 is a shorter string representation of node ID, mainly the first 8 characters.

Note that this method doesn't create a new collection but simply iterates over the input one.

Parameters:
ids - Collection of nodeIds.
Returns:
Collection of node IDs for given collection of grid nodes.

nodeAttributes

public static <T> Collection<T> nodeAttributes(Collection<? extends GridNode> nodes,
                                               String attr)
Convenient utility method that returns collection of node attributes for a given collection of grid nodes.

Note that this method doesn't create a new collection but simply iterates over the input one.

Type Parameters:
T - Type of the attribute.
Parameters:
nodes - Collection of grid nodes.
attr - Name of the attribute to return from each node.
Returns:
Collection of node attributes for given collection of grid nodes.

meta

public static <T> Collection<T> meta(Collection<? extends GridMetadataAware> objs,
                                     String name)
Convenient utility method that returns collections of metadata values for a given collection of metadata aware objects.

Note that this method doesn't create a new collection but simply iterates over the input one.

Type Parameters:
T - Type of the metadata.
Parameters:
objs - Collection of metadata aware object.
name - Name of the metadata.
Returns:
Collections of metadata value for a given collection of metadata aware objects.

println

public static <T> GridInClosure<T> println()
Gets closure that calls System.out.println() on its bound variable.

Type Parameters:
T - Type of the bound variable.
Returns:
Closure that calls System.out.println() on its bound variable.

println

public static GridAbsClosure println(String msg)
Creates absolute closure that does System.out.println(msg).

Parameters:
msg - Message to print.
Returns:
Absolute closure that print message.

print

public static GridAbsClosure print(String msg)
Creates absolute closure that does System.out.print(msg).

Parameters:
msg - Message to print.
Returns:
Absolute closure that print message.

println

public static <T> GridInClosure<T> println(@Nullable
                                           String pre,
                                           @Nullable
                                           String post)
Gets closure that prints out its bound variable.

Type Parameters:
T - Type of the bound variable.
Parameters:
pre - String value to print before each variable.
post - String value to print after each variable.
Returns:
Closure that calls System.out.print(pre); System.out.print(t); System.out.println(post) on its bound variable.

printf

public static <T> GridInClosure<T> printf(String fmt)
Gets closure that prints out its bound variable.

Type Parameters:
T - Type of the bound variable.
Parameters:
fmt - Format string as for PrintStream.printf(String, Object...) method.
Returns:
Closure that prints out its bound variable.

print

public static <T> GridInClosure<T> print()
Gets closure that prints out its bound variable

Returns:
Closure that prints out its bound variable.

print

public static <T> GridInClosure<T> print(@Nullable
                                         String pre,
                                         @Nullable
                                         String post)
Gets closure that prints out its bound variable.

Parameters:
pre - String value to print before each variable.
post - String value to print after each variable.
Returns:
Closure that prints out its bound variable.

opt

public static <T> GridAbsClosure opt(GridOpt<T> opt,
                                     GridInClosure<? super T> c)
Converts given option and closure into absolute closure that does nothing if option is a none value, or applies in closure if option is some value. Note that peer deployment information will be copied from given in closure.

Type Parameters:
T - Type of the option and closure's free variable.
Parameters:
opt - Option.
c - Closure to apply if option is some value.
Returns:
Absolute closure that does nothing if option is a none value, or applies input closure if option is some value.

opt

public static <T,R> GridOutClosure<R> opt(GridOpt<T> opt,
                                          GridClosure<T,R> c,
                                          R dfltVal)
Converts given option and closure into output closure that does nothing and returns default value if option is a none value, or applies input closure and returns its value if option is some value. Note that peer deployment information will be copied from given closure.

Type Parameters:
T - Type of the option and closure's free variable.
R - Type of the return value.
Parameters:
opt - Option.
c - Closure to apply if option is some value.
dfltVal - Default value to return in case if option is none value.
Returns:
Output closure that does nothing returns default value if option is a none value, or applies input closure and returns its value if option is some value.

rand

public static <T> T rand(Collection<? extends T> c)
Gets random value from given collection.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection.
Returns:
Random value from the input collection.

rand

public static <T> T rand(List<T> l)
Gets random value from given list. For random-access lists this operation is O(1), otherwise O(n).

Type Parameters:
T - Type of the list elements.
Parameters:
l - Input collection.
Returns:
Random value from the input list.

rand

public static <T> T rand(T... c)
Gets random value from given array. This operation does not iterate through array elements and returns immediately.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection.
Returns:
Random value from the input collection.

concat

public static <T> Collection<T> concat(boolean copy,
                                       @Nullable
                                       T t,
                                       @Nullable
                                       Collection<T> c)
Concatenates an element to a collection. If copy flag is true, then a new collection will be created and the element and passed in collection will be copied into the new one. The returned collection will be modifiable. If copy flag is false, then a read-only view will be created over the element and given collections and no copying will happen.

Type Parameters:
T - Element type.
Parameters:
copy - Copy flag.
t - First element.
c - Second collection.
Returns:
Concatenated collection.

concat

public static <T> Collection<T> concat(boolean copy,
                                       @Nullable
                                       Collection<T> c1,
                                       @Nullable
                                       Collection<T> c2)
Concatenates 2 collections into one. If copy flag is true, then a new collection will be created and these collections will be copied into the new one. The returned collection will be modifiable. If copy flag is false, then a read-only view will be created over given collections and no copying will happen.

Type Parameters:
T - Element type.
Parameters:
copy - Copy flag.
c1 - First collection.
c2 - Second collection.
Returns:
Concatenated non-null collection.

concat

public static <T> T[] concat(@Nullable
                             T[] arr,
                             T... obj)
Concatenates an elements to an array.

Parameters:
arr - Array.
obj - One or more elements.
Returns:
Concatenated array.

lose

public static <T0,T extends T0> Collection<T> lose(Collection<T> c,
                                                   boolean copy,
                                                   @Nullable
                                                   Collection<T0> filter)
Loses all elements in input collection that are contained in filter collection.

Type Parameters:
T - Type of collections.
Parameters:
c - Input collection.
copy - If true method creates new collection not modifying input, otherwise does in-place modifications.
filter - Filter collection. If filter collection is empty or null - no elements are lost.
Returns:
Collection of remaining elements

lose

public static <T> Collection<T> lose(Collection<T> c,
                                     boolean copy,
                                     @Nullable
                                     GridPredicate<? super T>... p)
Loses all elements in input collection that are evaluated to true by all given predicates.

Type Parameters:
T - Type of collections.
Parameters:
c - Input collection.
copy - If true method creates new collection without modifying the input one, otherwise does in-place modifications.
p - Predicates to filter by. If no predicates provided - no elements are lost.
Returns:
Collection of remaining elements.

lose

public static <T> Collection<T> lose(Collection<? extends T> c,
                                     boolean copy,
                                     int num)
Loses up to first num elements of the input collection.

Type Parameters:
T - Type of the collections.
Parameters:
c - Input collection.
copy - If true method creates new collection not modifying input, otherwise does in-place modifications.
num - Maximum number of elements to lose (the actual number can be less if the input collection contains less elements).
Returns:
Collection of remaining elements.

lose

public static <K,V> Map<K,V> lose(Map<K,V> m,
                                  boolean copy,
                                  @Nullable
                                  GridPredicate<? super Map.Entry<K,V>>... p)
Loses all entries in input map that are evaluated to true by all given predicates.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of the free variable for the predicate and type of map's values.
Parameters:
m - Map to filter.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicates to use for filtration. If none provided - original map will (or its copy) be returned.
Returns:
Filtered map.

loseKeys

public static <K,V> Map<K,V> loseKeys(Map<K,V> m,
                                      boolean copy,
                                      @Nullable
                                      GridPredicate<? super K>... p)
Loses all entries in input map which keys are evaluated to true by all given predicates.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of map's values.
Parameters:
m - Map to filter.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicates to use for filtration. If none provided - original map (or its copy) will be returned.
Returns:
Filtered map.

loseValues

public static <K,V> Map<K,V> loseValues(Map<K,V> m,
                                        boolean copy,
                                        @Nullable
                                        GridPredicate<? super V>... p)
Loses all entries in input map which values are evaluated to true by all given predicates.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of map's values.
Parameters:
m - Map to filter.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicates to use for filtration. If none provided - original map (or its copy) will be returned.
Returns:
Filtered map.

loseList

public static <T> List<T> loseList(List<T> c,
                                   boolean copy,
                                   @Nullable
                                   Collection<? super T> filter)
Loses all elements in input list that are contained in filter collection.

Type Parameters:
T - Type of list.
Parameters:
c - Input list.
copy - If true method creates new list not modifying input, otherwise does in-place modifications.
filter - Filter collection. If filter collection is empty or null - no elements are lost.
Returns:
List of remaining elements

loseSet

public static <T> Set<T> loseSet(Set<T> c,
                                 boolean copy,
                                 @Nullable
                                 Collection<? super T> filter)
Loses all elements in input set that are contained in filter collection.

Type Parameters:
T - Type of set.
Parameters:
c - Input set.
copy - If true method creates new list not modifying input, otherwise does in-place modifications.
filter - Filter collection. If filter collection is empty or null - no elements are lost.
Returns:
Set of remaining elements

drop

public static <T> Iterable<T> drop(Iterable<T> c,
                                   @Nullable
                                   GridPredicate<? super T>... p)
Removes elements in-place from given collection. All elements for which all given predicates, if any, evaluate to true will be removed from the passed in collection. Note that collection must support removal.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection that should support removal.
p - Optional set of predicates. If no predicates provided - no elements will be dropped and input collection will be returned.
Returns:
Input collection with some elements potentially removed.

node2id

public static GridClosure<GridNode,UUID> node2id()
Gets closure which converts node to node ID.

Returns:
Closure which converts node to node ID.

node2id8

public static GridClosure<GridNode,String> node2id8()
Gets closure which converts node to node ID8 representation (shorter and good enough).

Returns:
Closure which converts node to node ID8 representation (shorter and good enough).

id2id8

public static GridClosure<UUID,String> id2id8()
Gets closure which converts node ID to node ID8 representation (shorter and good enough).

Returns:
Closure which converts node ID to node ID8 representation (shorter and good enough).

nodeForNodeId

public static <T extends GridNode> GridPredicate<T> nodeForNodeId(UUID nodeId)
Creates grid node predicate evaluating on the given node ID.

Parameters:
nodeId - Node ID for which returning predicate will evaluate to true.
Returns:
Grid node predicate evaluating on the given node ID.
See Also:
GridFunc.idForNodeId(UUID), GridFunc.nodeIds(Collection)

nodeForNodeIds

public static <T extends GridNode> GridPredicate<T> nodeForNodeIds(@Nullable
                                                                   Collection<UUID> nodeIds)
Creates grid node predicate evaluating on the given node IDs.

Parameters:
nodeIds - Collection of node IDs.
Returns:
Grid node predicate evaluating on the given node IDs.
See Also:
GridFunc.idForNodeId(UUID), GridFunc.nodeIds(Collection)

nodeForNodeIds

public static <T extends GridNode> GridPredicate<T> nodeForNodeIds(@Nullable
                                                                   UUID... nodeIds)
Creates grid node predicate evaluating on the given node IDs.

Parameters:
nodeIds - Collection of node IDs.
Returns:
Grid node predicate evaluating on the given node IDs.
See Also:
GridFunc.idForNodeId(UUID), GridFunc.nodeIds(Collection)

idForNodeId

public static GridPredicate<UUID> idForNodeId(UUID nodeId)
Creates UUID predicate evaluating on the given node ID.

Parameters:
nodeId - Node ID for which returning predicate will evaluate to true.
Returns:
UUID predicate evaluating on the given node ID.
See Also:
GridFunc.nodeForNodeId(UUID), GridFunc.nodeIds(Collection)

idForNodeIds

public static GridPredicate<UUID> idForNodeIds(@Nullable
                                               Collection<UUID> nodeIds)
Creates UUID predicate evaluating on the given node IDs.

Parameters:
nodeIds - Collection of node IDs.
Returns:
UUID predicate evaluating on the given node IDs.
See Also:
GridFunc.nodeForNodeId(UUID), GridFunc.nodeIds(Collection)

idForNodeIds

public static GridPredicate<UUID> idForNodeIds(@Nullable
                                               UUID... nodeIds)
Creates UUID predicate evaluating on the given node IDs.

Parameters:
nodeIds - Collection of node IDs.
Returns:
UUID predicate evaluating on the given node IDs.
See Also:
GridFunc.nodeForNodeId(UUID), GridFunc.nodeIds(Collection)

nodeForNodes

public static GridPredicate<GridRichNode> nodeForNodes(@Nullable
                                                       Collection<? extends GridNode> nodes)
Creates predicates that evaluates to true for each node in given collection. Note that is collection is empty the result predicate will always evaluate to false. Implementation simply creates GridNodePredicate instance.

Parameters:
nodes - Collection of nodes. If none provided - result predicate will always return false.
Returns:
Predicates that evaluates to true for each node in given collection.

nodeForNodes

public static GridPredicate<GridRichNode> nodeForNodes(GridRichNode... nodes)
Creates predicates that evaluates to true for each node in given collection. Note that if collection is empty the result predicate will always evaluate to false. Implementation simply creates GridNodePredicate instance.

Parameters:
nodes - Collection of nodes. If none provided - result predicate will always return false.
Returns:
Predicates that evaluates to true for each node in given collection.

retain

public static <T0,T extends T0> Collection<T> retain(Collection<T> c,
                                                     boolean copy,
                                                     @Nullable
                                                     Collection<? extends T0> filter)
Retains all elements in input collection that are contained in filter.

Type Parameters:
T - Type of collections.
Parameters:
c - Input collection.
copy - If true method creates collection not modifying input, otherwise does in-place modifications.
filter - Filter collection. If filter collection is null or empty - an empty collection will be returned.
Returns:
Collection of retain elements.

retain

public static <T> Collection<T> retain(Collection<T> c,
                                       boolean copy,
                                       @Nullable
                                       GridPredicate<? super T>... p)
Retains all elements in input collection that are evaluated to true by all given predicates.

Type Parameters:
T - Type of collections.
Parameters:
c - Input collection.
copy - If true method creates collection not modifying input, otherwise does in-place modifications.
p - Predicates to filter by. If no predicates provides - all elements will be retained.
Returns:
Collection of retain elements.

retain

public static <T> Collection<T> retain(Collection<T> c,
                                       boolean copy,
                                       int num)
Retains only up to first num elements in the input collection.

Type Parameters:
T - Type of the collections.
Parameters:
c - Input collection.
copy - If true method creates collection not modifying input, otherwise does in-place modifications.
num - Maximum number of elements to retain (the actual number can be less if the input collection contains less elements).
Returns:
Collection contains up to num first elements from the input collection.

retain

public static <K,V> Map<K,V> retain(Map<K,V> m,
                                    boolean copy,
                                    @Nullable
                                    GridPredicate<? super Map.Entry<K,V>>... p)
For a given map retains all map entries that satisfy all provided predicates. If no predicates provided - all entries will be retain.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of map's values.
Parameters:
m - Map to retain entries from.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicate to use for filtration. If none provided - original map (or its copy) will be returned.
Returns:
Filtered map.

retainKeys

public static <K,V> Map<K,V> retainKeys(Map<K,V> m,
                                        boolean copy,
                                        @Nullable
                                        GridPredicate<? super K>... p)
For a given map retains all map entries which keys satisfy all provided predicates. If no predicates provided - all entries will be retain.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of map's values.
Parameters:
m - Map to retain entries from.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicate to use for filtration. If none provided - original map (or its copy) will be returned.
Returns:
Filtered map.

retainValues

public static <K,V> Map<K,V> retainValues(Map<K,V> m,
                                          boolean copy,
                                          @Nullable
                                          GridPredicate<? super V>... p)
For a given map retains all map entries which values satisfy all provided predicates. If no predicates provided - all entries will be retain and the same map will be returned.

Type Parameters:
K - Type of the free variable for the predicate and type of map's keys.
V - Type of map's values.
Parameters:
m - Map to retain entries from.
copy - If true method creates new map not modifying input, otherwise does in-place modifications.
p - Optional set of predicate to use for filtration. If none provided - original map (or its copy) will be returned.
Returns:
Filtered map.

outJobs

public static <T extends Callable<?>> Collection<GridJob> outJobs(@Nullable
                                                                  Collection<? extends T> c)
Converts collection of out closures to the read only collection of grid jobs.

Parameters:
c - Closure collection to convert.
Returns:
Read only collection of grid job where each job wraps corresponding closure from input collection.

absJobs

public static <T extends Runnable> Collection<GridJob> absJobs(@Nullable
                                                               Collection<? extends T> c)
Converts collection of absolute closures to the read only collection of grid jobs.

Parameters:
c - Closure collection to convert.
Returns:
Read only collection of grid job where each job wraps corresponding closure from input collection.

outJobs

public static Collection<GridJob> outJobs(@Nullable
                                          Callable<?>... c)
Converts array of out closures to the collection of grid jobs.

Parameters:
c - Closure array to convert.
Returns:
Collection of grid job where each job wraps corresponding closure from input array.

absJobs

public static Collection<GridJob> absJobs(@Nullable
                                          Runnable... c)
Converts array of out closures to the collection of grid jobs.

Parameters:
c - Closure array to convert.
Returns:
Collection of grid job where each job wraps corresponding closure from input array.

job

public static GridJob job(Callable<?> c)
Converts given closure to a grid job.

Parameters:
c - Closure to convert to grid job.
Returns:
Grid job made out of closure.

job

public static GridJob job(Runnable r)
Converts given closure to a grid job.

Parameters:
r - Closure to convert to grid job.
Returns:
Grid job made out of closure.

as

public static <T> GridOutClosure as(Future<T> fut)
Converts given future into the closure. When result closure's apply method is called it will call Future.get() method.

Type Parameters:
T - Type of the future and closure.
Parameters:
fut - Future to convert.
Returns:
Out closure that wraps given future.

as0

public static <E1,E2> GridPredicate<GridTuple2<E1,E2>> as0(GridPredicate2<? super E1,? super E2> p)
Converts predicate with two separate values to a predicate with tuple.

Type Parameters:
E1 - Type of the 1st value.
E2 - Type of the 2nd value.
Parameters:
p - Predicate to convert.
Returns:
Converted predicate.

as

public static <T> Future<T> as(GridFuture<T> fut)
Converts given object with interface GridFuture into an object implementing Future.

Type Parameters:
T - Type of computation result.
Parameters:
fut - Future to convert.
Returns:
Instance implementing Future.

future

public static <T> GridClosure<GridFuture<T>,Future<T>> future()
Gets closure that converts GridFuture to Future.

Type Parameters:
T - Type of future.
Returns:
Closure that converts GridFuture to Future.

whileDo

public static void whileDo(GridAbsClosure body,
                           GridAbsPredicate cond)
Executes given body until provided condition evaluates to true via while-do Java loop (test-before).

Parameters:
body - Body closure.
cond - Condition predicate.

doWhile

public static void doWhile(GridAbsClosure body,
                           GridAbsPredicate cond)
Executes given body until provided condition evaluates to true via do-while Java loop (test-after).

Parameters:
body - Body closure.
cond - Condition predicate.

doWhile

public static <R> GridOpt<R> doWhile(Callable<R> body,
                                     GridAbsPredicate cond)
Executes given body until provided condition evaluates to true via do-while Java loop (test-after).

Throws:
GridClosureException - Thrown if callable throws exception.
Type Parameters:
R - Type of closure's return value.
Parameters:
body - Body closure.
cond - Condition predicate.
Returns:
Last return value of the closure.

whileDo

public static <R> GridOpt<R> whileDo(Callable<R> body,
                                     GridAbsPredicate cond)
Executes given body until provided condition evaluates to true via while-do Java loop (test-before).

Throws:
GridClosureException - Thrown if callable throws exception.
Type Parameters:
R - Type of closure's return value.
Parameters:
body - Body closure.
cond - Condition predicate.
Returns:
Last return value of the closure.

yield

public static <T,R> Collection<GridOutClosure<R>> yield(Collection<? extends T> c,
                                                        GridClosure<? super T,R> f)
Given collection of items and a closure this method returns read only collection of closures where each closure is closed on an element of the initial collection.

Type Parameters:
T - Type of the input collection.
R - Type of the return value for the closure.
Parameters:
c - Input collection of elements.
f - Closure to close on each element of input collection.
Returns:
Read only collection of closures closed on each element of input collection.

yield

public static <T> Collection<GridAbsClosure> yield(Collection<? extends T> c,
                                                   GridInClosure<? super T> f)
Given collection of items and a closure this method returns read-only collection of closures where each closure is closed on an element of the initial collection.

Type Parameters:
T - Type of the input collection.
Parameters:
c - Input collection of elements.
f - Closure to close on each element of input collection.
Returns:
Read only collection of closures closed on each element of input collection.

yield

public static <T> Collection<GridAbsClosure> yield(T[] c,
                                                   GridInClosure<? super T> f)
Given collection of items and a closure this method returns collection of closures where each closure is closed on an element of the initial collection.

Type Parameters:
T - Type of the input collection.
Parameters:
c - Input collection of elements.
f - Closure to close on each element of input collection.
Returns:
Collection of closures closed on each element of input collection.

yield

public static <T,R> Collection<GridOutClosure<R>> yield(T[] c,
                                                        GridClosure<? super T,R> f)
Given array of items and a closure this method returns collection of closures where each closure is closed on a element of the array.

Type Parameters:
T - Type of the input collection.
R - Type of the return value for the closure.
Parameters:
c - Input array of elements.
f - Closure to close on each element of array.
Returns:
Collection of closures closed on each element of array.

as

public static <T> GridIterable<T> as(Iterator<T> iter)
Converts given iterator into instance of Iterable interface.

Type Parameters:
T - Type of the iterator.
Parameters:
iter - Iterator to convert.
Returns:
Iterable over given iterator.

asList

public static <T> List<T> asList(@Nullable
                                 T... vals)
Converts array to List. Note that resulting list cannot be altered in size, as it it based on the passed in array - only current elements can be changed.

Note that unlike Arrays.asList(Object[]), this method is null-safe. If null is passed in, then empty list will be returned.

Type Parameters:
T - Array type.
Parameters:
vals - Array of values
Returns:
List instance for array.

emptyIterator

public static <T> GridIterator<T> emptyIterator()
Creates new empty iterator.

Type Parameters:
T - Type of the iterator.
Returns:
Newly created empty iterator.

flat

public static <T> Collection<T> flat(@Nullable
                                     Collection<? extends Collection<T>> c)
Flattens collection-of-collections and returns collection over the elements of the inner collections. This method doesn't create any new collections or copies any elements.

Note that due to non-copying nature of implementation, the size() method of resulting collection will have to iterate over all elements to produce size. Method isEmpty(), however, is constant time and is much more preferable to use instead of 'size()' method when checking if list is not empty.

Type Parameters:
T - Type of the inner collections.
Parameters:
c - Input collection of collections.
Returns:
Iterable over the elements of the inner collections.

flat

public static <T> GridIterator<T> flat(@Nullable
                                       Iterable<? extends Iterable<T>> c)
Flattens iterable-of-iterables and returns iterable over the elements of the inner collections. This method doesn't create any new collections or copies any elements.

Type Parameters:
T - Type of the inner collections.
Parameters:
c - Input collection of collections.
Returns:
Iterable over the elements of the inner collections.

flat0

public static Collection<Object> flat0(@Nullable
                                       Object... objs)
Flattens given set objects into a single collection. Unrolls Collection, Iterable and Object[] objects.

Parameters:
objs - Objects to flatten.
Returns:
Flattened collection.

as

public static GridAbsClosure as(@Nullable
                                Runnable r)
Converts given runnable to an absolute closure.

Parameters:
r - Runnable to convert to closure. If null - no-op closure is returned.
Returns:
Closure that wraps given runnable. Note that wrapping closure always returns null.

r2c

public static GridClosure<Runnable,GridAbsClosure> r2c()
Returns closure that converts Runnable to GridAbsClosure.

Returns:
closure that converts Runnable to GridAbsClosure.

c2c

public static <T> GridClosure<Callable<T>,GridOutClosure<T>> c2c()
Returns closure that converts Callable to GridOutClosure.

Returns:
closure that converts Callable to GridOutClosure.

as

public static <R> GridOutClosure<R> as(Callable<R> c)
Converts given callable to an out-closure.

Parameters:
c - Callable to convert to closure.
Returns:
Out-closure that wraps given callable. Note that if callable throw exception the wrapping closure will re-throw it as GridRuntimeException.

size

public static <T> int size(T[] c,
                           @Nullable
                           GridPredicate<? super T>... p)
Gets size of the given array with provided optional predicates.

Type Parameters:
T - Type of the array.
Parameters:
c - Array to size.
p - Optional predicates that filters out elements from count.
Returns:
Number of elements in the array for which all given predicates evaluates to true. If no predicates is provided - all elements are counted.

size

public static <T> int size(@Nullable
                           Collection<? extends T> c,
                           @Nullable
                           GridPredicate<? super T>... p)
Gets size of the given collection with provided optional predicates.

Type Parameters:
T - Type of the iterator.
Parameters:
c - Collection to size.
p - Optional predicates that filters out elements from count.
Returns:
Number of elements in the collection for which all given predicates evaluates to true. If no predicates is provided - all elements are counted.

size

public static <T> int size(@Nullable
                           Iterator<? extends T> it,
                           @Nullable
                           GridPredicate<? super T>... p)
Gets size of the given iterator with provided optional predicates. Iterator will be traversed to get the count.

Type Parameters:
T - Type of the iterator.
Parameters:
it - Iterator to size.
p - Optional predicates that filters out elements from count.
Returns:
Number of elements in the iterator for which all given predicates evaluates to true. If no predicates is provided - all elements are counted.

view

public static <T> Collection<T> view(@Nullable
                                     Collection<T> c,
                                     @Nullable
                                     GridPredicate<? super T>... p)
Creates write-through light-weight view on given collection with provided predicates. Resulting collection will only "have" elements for which all provided predicate, if any, evaluates to true. Note that only wrapping collection will be created and no duplication of data will occur. Also note that if array of given predicates is not empty then method size() uses full iteration through the collection.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection that serves as a base for the view.
p - Optional predicated. If predicates are not provided - all elements will be in the view.
Returns:
Light-weight view on given collection with provided predicate.

viewReadOnly

public static <T1,T2> Collection<T2> viewReadOnly(@Nullable
                                                  Collection<? extends T1> c,
                                                  GridClosure<? super T1,T2> trans,
                                                  @Nullable
                                                  GridPredicate<? super T1>... p)
Creates read-only light-weight view on given collection with transformation and provided predicates. Resulting collection will only "have" transformed elements for which all provided predicate, if any, evaluates to true. Note that only wrapping collection will be created and no duplication of data will occur. Also note that if array of given predicates is not empty then method size() uses full iteration through the collection.

Type Parameters:
T1 - Type of the collection.
Parameters:
c - Input collection that serves as a base for the view.
trans - Transformation closure.
p - Optional predicated. If predicates are not provided - all elements will be in the view.
Returns:
Light-weight view on given collection with provided predicate.

viewListReadOnly

public static <T1,T2> List<T2> viewListReadOnly(@Nullable
                                                List<? extends T1> c,
                                                GridClosure<? super T1,T2> trans)
Creates read-only light-weight view on given list with provided transformation. Resulting list will only "have" transformed elements. Note that only wrapping list will be created and no duplication of data will occur.

Type Parameters:
T1 - Type of the list.
Parameters:
c - Input list that serves as a base for the view.
trans - Transformation closure.
Returns:
Light-weight view on given list with provided transformation.

transformList

public static <T1,T2> List<T2> transformList(Collection<? extends T1> c,
                                             GridClosure<? super T1,T2> trans,
                                             @Nullable
                                             GridPredicate<? super T1>... p)
Creates a view on given list with provided transformer and predicates. Resulting list will only "have" elements for which all provided predicates, if any, evaluate to true. Note that a new collection will be created and data will be copied.

Parameters:
c - Input list that serves as a base for the view.
trans - Transforming closure from T1 to T2.
p - Optional predicates. If predicates are not provided - all elements will be in the view.
Returns:
View on given list with provided predicate.

transformSet

public static <T1,T2> Set<T2> transformSet(Collection<? extends T1> c,
                                           GridClosure<? super T1,T2> trans,
                                           @Nullable
                                           GridPredicate<? super T1>... p)
Creates a view on given set with provided transformer and predicates. Resulting set will only "have" elements for which all provided predicates, if any, evaluate to true. Note that a new collection will be created and data will be copied.

Parameters:
c - Input set that serves as a base for the view.
trans - Transforming closure from T1 to T2.
p - Optional predicates. If predicates are not provided - all elements will be in the view.
Returns:
View on given set with provided predicate.

view

public static <K0,K extends K0,V0,V extends V0> Map<K,V> view(@Nullable
                                                              Map<K,V> m,
                                                              @Nullable
                                                              GridPredicate<? super K>... p)
Creates light-weight view on given map with provided predicates. Resulting map will only "have" keys for which all provided predicates, if any, evaluates to true. Note that only wrapping map will be created and no duplication of data will occur. Also note that if array of given predicates is not empty then method size() uses full iteration through the entry set.

Type Parameters:
K - Type of the key.
V - Type of the value.
Parameters:
m - Input map that serves as a base for the view.
p - Optional predicates. If predicates are not provided - all will be in the view.
Returns:
Light-weight view on given map with provided predicate.

viewReadOnly

public static <K0,K extends K0,V0,V extends V0,V1> Map<K,V1> viewReadOnly(@Nullable
                                                                          Map<K,V> m,
                                                                          GridClosure<V,V1> trans,
                                                                          @Nullable
                                                                          GridPredicate<? super K>... p)
Read-only view on map that supports transformation of values and key filtering. Resulting map will only "have" keys for which all provided predicates, if any, evaluates to true. Note that only wrapping map will be created and no duplication of data will occur. Also note that if array of given predicates is not empty then method size() uses full iteration through the entry set.

Type Parameters:
K - Type of the key.
V - Type of the input map value.
V1 - Type of the output map value.
Parameters:
m - Input map that serves as a base for the view.
trans - Transformer for map value transformation.
p - Optional predicates. If predicates are not provided - all will be in the view.
Returns:
Light-weight view on given map with provided predicate and transformer.

isEmpty

public static boolean isEmpty(@Nullable
                              String s)
Tests if given string is null or empty.

Parameters:
s - String to test.
Returns:
Whether or not the given string is null or empty.

isEmpty

public static <T> boolean isEmpty(@Nullable
                                  T[] c)
Tests if the given array is either null or empty.

Parameters:
c - Array to test.
Returns:
Whether or not the given array is null or empty.

isEmpty

public static boolean isEmpty(@Nullable
                              int[] c)
Tests if the given array is either null or empty.

Parameters:
c - Array to test.
Returns:
Whether or not the given array is null or empty.

isEmpty

public static boolean isEmpty(@Nullable
                              Iterable<?> c)
Tests if the given collection is either null or empty.

Parameters:
c - Collection to test.
Returns:
Whether or not the given collection is null or empty.

isEmpty

public static boolean isEmpty(@Nullable
                              Collection<?> c)
Tests if the given collection is either null or empty.

Parameters:
c - Collection to test.
Returns:
Whether or not the given collection is null or empty.

isEmpty

public static boolean isEmpty(@Nullable
                              Map<?,?> m)
Tests if the given map is either null or empty.

Parameters:
m - Map to test.
Returns:
Whether or not the given collection is null or empty.

returnIfAbsent

@Nullable
public static <K,V> V returnIfAbsent(Map<? extends K,? extends V> map,
                                              @Nullable
                                              K key,
                                              @Nullable
                                              Callable<V> c)
Utility map getter. This method analogous to GridFunc.addIfAbsent(Map, Object, Callable) method but this one doesn't put the default value into the map when key is not found.

Throws:
GridClosureException - Thrown in case when callable throws exception.
Type Parameters:
K - Map key type.
V - Map value type.
Parameters:
map - Map to get value from.
key - Map key (can be null).
c - Optional factory closure for the default value to be returned in when key is not found. If closure is not provided - null will be returned.
Returns:
Value for the key or default value produced by c if key is not found (or null if key is not found and closure is not provided).
See Also:
GridFunc.newLinkedList(), GridFunc.newList(), GridFunc.newSet(), GridFunc.newMap(), GridFunc.newAtomicLong(), GridFunc.newAtomicInt(), GridFunc.newAtomicRef(), GridFunc.newAtomicBoolean()

newList

public static <T> GridOutClosure<List<T>> newList()
Returns a factory closure that creates new List instance. Note that this method does not create a new closure but returns a static one.

Type Parameters:
T - Type parameters for the created List.
Returns:
Factory closure that creates new List instance every time its GridOutClosure.apply() method is called.

newAtomicInt

public static GridOutClosure<AtomicInteger> newAtomicInt()
Returns a factory closure that creates new AtomicInteger instance initialized to zero. Note that this method does not create a new closure but returns a static one.

Returns:
Factory closure that creates new AtomicInteger instance initialized to zero every time its GridOutClosure.apply() method is called.

newAtomicLong

public static GridOutClosure<AtomicLong> newAtomicLong()
Returns a factory closure that creates new AtomicLong instance initialized to zero. Note that this method does not create a new closure but returns a static one.

Returns:
Factory closure that creates new AtomicLong instance initialized to zero every time its GridOutClosure.apply() method is called.

newAtomicRef

public static <T> GridOutClosure<AtomicReference<T>> newAtomicRef()
Returns a factory closure that creates new AtomicReference instance initialized to null. Note that this method does not create a new closure but returns a static one.

Type Parameters:
T - Type of the atomic reference.
Returns:
Factory closure that creates new AtomicReference instance initialized to null every time its GridOutClosure.apply() method is called.

newAtomicBoolean

public static GridOutClosure<AtomicBoolean> newAtomicBoolean()
Returns a factory closure that creates new AtomicBoolean instance initialized to false. Note that this method does not create a new closure but returns a static one.

Returns:
Factory closure that creates new AtomicBoolean instance initialized to false every time its GridOutClosure.apply() method is called.

newLinkedList

public static <T> GridOutClosure<LinkedList<T>> newLinkedList()
Returns a factory closure that creates new LinkedList instance. Note that this method does not create a new closure but returns a static one.

Type Parameters:
T - Type parameters for the created LinkedList.
Returns:
Factory closure that creates new LinkedList instance every time its GridOutClosure.apply() method is called.

newSet

public static <T> GridOutClosure<Set<T>> newSet()
Returns a factory closure that creates new Set instance. Note that this method does not create a new closure but returns a static one.

Type Parameters:
T - Type parameters for the created Set.
Returns:
Factory closure that creates new Set instance every time its GridOutClosure.apply() method is called.

newMap

public static <K,V> GridOutClosure<Map<K,V>> newMap()
Returns a factory closure that creates new Map instance. Note that this method does not create a new closure but returns a static one.

Type Parameters:
K - Type of the key for the created Map.
V - Type of the value for the created Map.
Returns:
Factory closure that creates new Map instance every time its GridOutClosure.apply() method is called.

newCMap

public static <K,V> GridOutClosure<ConcurrentMap<K,V>> newCMap()
Returns a factory closure that creates new ConcurrentMap instance. Note that this method does not create a new closure but returns a static one.

Type Parameters:
K - Type of the key for the created ConcurrentMap.
V - Type of the value for the created ConcurrentMap.
Returns:
Factory closure that creates new Map instance every time its GridOutClosure.apply() method is called.

newCSet

public static <E> GridOutClosure<Set<E>> newCSet()
Returns a factory closure that creates new GridConcurrentHashSet instance. Note that this method does not create a new closure but returns a static one.

Returns:
Factory closure that creates new GridConcurrentHashSet instance every time its GridOutClosure.apply() method is called.

iterable

public static <T> GridIterable<T> iterable(Collection<? extends T> c,
                                           GridPredicate<? super T>... p)
Creates and returns iterable from given collection and optional filtering predicates. Returned iterable collection will only have elements for which all given predicates evaluates to true. Note that this method will not create new collection but will simply "skip" elements in the provided collection that given predicates doesn't evaluate to true for.

Type Parameters:
T - Type of the collection elements.
Parameters:
c - Input collection.
p - Optional filtering predicates.
Returns:
Iterable from given collection and optional filtering predicates.

producer

public static <T> GridOutClosure<T> producer(Iterable<? extends T> c,
                                             boolean cyclic)
Gets closure that wraps access to the given collection. Every time resulting closure is called it will return the next element in the input collection.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection.
cyclic - Determines whether input collection will rewind when end is reached and start again from the beginning - or NoSuchElementException exception is thrown.
Returns:
Out closure that wraps access to input collection.
See Also:
GridFunc.jobProducer(GridJob[], boolean)

producer

public static <T> GridOutClosure<T> producer(T[] c,
                                             boolean cyclic)
Gets closure that wraps access to the given collection. Every time resulting closure is called it will return the next element in the input collection.

Type Parameters:
T - Type of the collection.
Parameters:
c - Input collection.
cyclic - Determines whether input collection will rewind when end is reached and start again from the beginning - or NoSuchElementException exception is thrown.
Returns:
Out closure that wraps access to input collection.
See Also:
GridFunc.jobProducer(GridJob[], boolean)

jobProducer

public static GridOutClosure<GridJob> jobProducer(GridJob[] c,
                                                  boolean cyclic)
Gets closure that wraps access to the given collection of GridJob instances. Every time resulting closure is called it will return the next job in the input collection. Note that this method will wrap job from input collection using GridJobWrapper class before returning it. It is convenient when the resulting closure is used to produce jobs that server as map's keys.

Parameters:
c - Input jobs array.
cyclic - Determines whether input collection will rewind when end is reached and start again from the beginning - or NoSuchElementException exception is thrown.
Returns:
Out closure that wraps access to input collection.
See Also:
GridFunc.producer(Object[], boolean), GridFunc.producer(Iterable, boolean)

jobProducer

public static GridOutClosure<GridJob> jobProducer(Iterable<? extends GridJob> jobs,
                                                  boolean cyclic)
Gets closure that wraps access to the given collection of GridJob instances. Every time resulting closure is called it will return the next job in the input collection. Note that this method will wrap job from input collection using GridJobWrapper class before returning it. It is convenient when the resulting closure is used to produce jobs that server as map's keys.

Parameters:
jobs - Input jobs collection.
cyclic - Determines whether input collection will rewind when end is reached and start again from the beginning - or NoSuchElementException exception is thrown.
Returns:
Out closure that wraps access to input collection.
See Also:
GridFunc.producer(Object[], boolean), GridFunc.producer(Iterable, boolean)

iterator0

public static <T> GridIterator<T> iterator0(Collection<? extends T> c,
                                            boolean readOnly,
                                            GridPredicate<? super T>... p)
Creates and returns iterator from given collection and optional filtering predicates. Returned iterator will only have elements for which all given predicates evaluates to true (if provided). Note that this method will not create new collection but will simply "skip" elements in the provided collection that given predicates doesn't evaluate to true for.

Type Parameters:
T - Type of the collection elements.
Parameters:
c - Input collection.
readOnly - If true, then resulting iterator will not allow modifications to the underlying collection.
p - Optional filtering predicates.
Returns:
Iterator from given collection and optional filtering predicate.

iterator

public static <T1,T2> GridIterator<T2> iterator(Collection<? extends T1> c,
                                                GridClosure<? super T1,T2> trans,
                                                boolean readOnly,
                                                @Nullable
                                                GridPredicate<? super T1>... p)
Creates and returns transforming iterator from given collection and optional filtering predicates. Returned iterator will only have elements for which all given predicates evaluates to true ( if provided). Note that this method will not create new collection but will simply "skip" elements in the provided collection that given predicates doesn't evaluate to true for.

Type Parameters:
T1 - Type of the collection elements.
T2 - Type of returned elements.
Parameters:
c - Input collection.
trans - Transforming closure to convert from T1 to T2.
readOnly - If true, then resulting iterator will not allow modifications to the underlying collection.
p - Optional filtering predicates.
Returns:
Iterator from given collection and optional filtering predicate.

alwaysTrue

public static <T> GridPredicate<T> alwaysTrue()
Gets predicate that always returns true. This method returns constant predicate.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Returns:
Predicate that always returns true.

alwaysFalse

public static <T> GridPredicate<T> alwaysFalse()
Gets predicate that always returns false. This method returns constant predicate.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Returns:
Predicate that always returns false.

isAlwaysTrue

public static boolean isAlwaysTrue(GridPredicate p)
Tests whether or not given predicate is the one returned from GridFunc.alwaysTrue() method.

Parameters:
p - Predicate to check.
Returns:
true if given predicate is ALWAYS_TRUE predicate.

isAlwaysTrue

public static boolean isAlwaysTrue(@Nullable
                                   GridPredicate[] p)
Tests whether or not given set of predicates consists only of one predicate returned from GridFunc.alwaysTrue() method.

Parameters:
p - Predicate to check.
Returns:
true if given contains only ALWAYS_TRUE predicate.

isAlwaysFalse

public static boolean isAlwaysFalse(GridPredicate p)
Tests whether or not given predicate is the one returned from GridFunc.alwaysFalse() method.

Parameters:
p - Predicate to check.
Returns:
true if given predicate is ALWAYS_FALSE predicate.

isAlwaysFalse

public static boolean isAlwaysFalse(@Nullable
                                    GridPredicate[] p)
Tests whether or not given set of predicates consists only of one predicate returned from GridFunc.alwaysFalse() method.

Parameters:
p - Predicate to check.
Returns:
true if given contains only ALWAYS_FALSE predicate.

isNull

public static <T> GridPredicate<T> isNull()
Gets predicate that evaluates to true if its free variable is null.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Returns:
Predicate that evaluates to true if its free variable is null.

notNull

public static <T> GridPredicate<T> notNull()
Gets predicate that evaluates to true if its free variable is not null.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Returns:
Predicate that evaluates to true if its free variable is not null.

not

public static <T> GridPredicate<T> not(@Nullable
                                       GridPredicate<? super T>... p)
Negates given predicates.

Gets predicate that evaluates to true if any of given predicates evaluates to false. If all predicates evaluate to true the result predicate will evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
p - Predicate to negate.
Returns:
Negated predicate.

equalTo

public static <T> GridPredicate<T> equalTo(@Nullable
                                           T target)
Gets predicate that evaluates to true if its free variable is equal to target or both are null.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
target - Object to compare free variable to.
Returns:
Predicate that evaluates to true if its free variable is equal to target or both are null.

notEqualTo

public static <T> GridPredicate<T> notEqualTo(@Nullable
                                              T target)
Gets predicate that evaluates to true if its free variable is not equal to target or both are null.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
target - Object to compare free variable to.
Returns:
Predicate that evaluates to true if its free variable is not equal to target or both are null.

instanceOf

public static <T> GridPredicate<T> instanceOf(Class<?> cls)
Gets predicate that evaluates to true if its free variable is instance of the given class.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
cls - Class to compare to.
Returns:
Predicate that evaluates to true if its free variable is instance of the given class.

notInstanceOf

public static <T> GridPredicate<T> notInstanceOf(Class<?> cls)
Gets predicate that evaluates to true if its free variable is not an instance of the given class.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
cls - Class to compare to.
Returns:
Predicate that evaluates to true if its free variable is not an instance of the given class.

first

@Nullable
public static <T> T first(@Nullable
                                   Iterable<? extends T> c)
Gets first element from given collection or returns null if the collection is empty.

Type Parameters:
T - Type of the collection.
Parameters:
c - A collection.
Returns:
Collections' first element or null in case if the collection is empty.

last

@Nullable
public static <T> T last(@Nullable
                                  Iterable<? extends T> c)
Gets last element from given collection or returns null if the collection is empty.

Type Parameters:
T - Type of the collection.
Parameters:
c - A collection.
Returns:
Collections' first element or null in case if the collection is empty.

firstValue

@Nullable
public static <V> V firstValue(Map<?,V> m)
Gets first value from given map or returns null if the map is empty.

Type Parameters:
V - Value type.
Parameters:
m - A map.
Returns:
Maps' first value or null in case if the map is empty.

firstKey

@Nullable
public static <K> K firstKey(Map<K,?> m)
Gets first key from given map or returns null if the map is empty.

Type Parameters:
K - Key type.
Parameters:
m - A map.
Returns:
Maps' first key or null in case if the map is empty.

firstEntry

@Nullable
public static <K,V> Map.Entry firstEntry(Map<K,V> m)
Gets first key from given map or returns null if the map is empty.

Type Parameters:
K - Key type.
V - Value type.
Parameters:
m - A map.
Returns:
Map's first entry or null in case if the map is empty.

and

public static <T> GridPredicate<T> and(@Nullable
                                       Collection<? extends GridPredicate<? super T>> ps)
Get a predicate that evaluates to true if each of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to false. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
ps - Passed in predicate.
Returns:
Predicate that evaluates to true if each of its component predicates evaluates to true.

and

public static <T> GridPredicate<T> and(@Nullable
                                       GridPredicate<? super T>[] p1,
                                       @Nullable
                                       GridPredicate<? super T>... p2)
Get a predicate that evaluates to true if each of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to false. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
p1 - Passed in predicates.
p2 - Passed in predicates.
Returns:
Predicate that evaluates to true if each of its component predicates evaluates to true.

and

public static <T> GridPredicate<T> and(@Nullable
                                       GridPredicate<? super T>... ps)
Get a predicate that evaluates to true if each of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to false. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
ps - Passed in predicate. If none provided - always-false predicate is returned.
Returns:
Predicate that evaluates to true if each of its component predicates evaluates to true.

or

public static <T> GridPredicate<T> or(@Nullable
                                      Collection<? extends GridPredicate<? super T>> ps)
Get a predicate that evaluates to true if any of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to true. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
ps - Passed in predicate.
Returns:
Predicate that evaluates to true if any of its component predicates evaluates to true.

or

public static <T> GridPredicate<T> or(@Nullable
                                      GridPredicate<? super T>[] p1,
                                      @Nullable
                                      GridPredicate<? super T>... p2)
Get a predicate that evaluates to true if any of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to false. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
p1 - Passed in predicates.
p2 - Passed in predicates.
Returns:
Predicate that evaluates to true if any of its component predicates evaluates to true.

or

public static <T> GridPredicate<T> or(@Nullable
                                      GridPredicate<? super T>... ps)
Get a predicate that evaluates to true if any of its component predicates evaluates to true. The components are evaluated in order they are supplied. Evaluation will be stopped as soon as first predicate evaluates to true. Passed in predicates are NOT copied. If no predicates are passed in the returned predicate will always evaluate to false.

Type Parameters:
T - Type of the free variable, i.e. the element the predicate is called on.
Parameters:
ps - Passed in predicate.
Returns:
Predicate that evaluates to true if any of its component predicates evaluates to true.

compose

public static <X,Y> GridPredicate<X> compose(GridPredicate<? super Y> p,
                                             GridClosure<? super X,? extends Y> f)
Gets a predicate that is composed of given predicate and closure. For every x it returns predicate p(f(x)). Note that predicate and closure must be loaded by the same class loader.

Type Parameters:
X - Type of the free variable for the closure.
Y - Type of the closure's return value.
Parameters:
p - Predicate.
f - Closure.
Returns:
Predicate that is composed of given predicate and closure.

constant1

public static <T1,R> GridClosure<T1,R> constant1(@Nullable
                                                 R val)
Gets closure that returns constant value.

Type Parameters:
T1 - Type of the free variable for the closure.
R - Type of the closure's return value.
Parameters:
val - Constant value to return.
Returns:
Closure that returns constant value.

constant2

public static <T1,T2,R> GridClosure2<T1,T2,R> constant2(@Nullable
                                                        R val)
Gets closure that returns constant value.

Type Parameters:
T1 - Type of the free variable for the closure.
T2 - Type of the free variable for the closure.
R - Type of the closure's return value.
Parameters:
val - Constant value to return.
Returns:
Closure that returns constant value.

constant3

public static <T1,T2,T3,R> GridClosure3<T1,T2,T3,R> constant3(@Nullable
                                                              R val)
Gets closure that returns constant value.

Type Parameters:
T1 - Type of the free variable for the closure.
T2 - Type of the free variable for the closure.
T3 - Type of the free variable for the closure.
R - Type of the closure's return value.
Parameters:
val - Constant value to return.
Returns:
Closure that returns constant value.

constant

public static <R> GridOutClosure<R> constant(@Nullable
                                             R val)
Gets closure that returns constant value.

Type Parameters:
R - Type of the closure's return value.
Parameters:
val - Constant value to return.
Returns:
Closure that returns constant value.

factory

public static <T> GridOutClosure<T> factory(Class<T> cls)
Creates and returns new factory closure for the given type.

Type Parameters:
T - Type of factory.
Parameters:
cls - Class of factory.
Returns:
Factory closure for the given type.

identity

public static <T> GridClosure<T,T> identity()
Gets identity closure, i.e. the closure that returns its variable value.

Type Parameters:
T - Type of the variable and return value for the closure.
Returns:
Identity closure, i.e. the closure that returns its variable value.

as

public static GridAbsPredicate as(Callable<Boolean> c)
Converts given closure to predicate.

Parameters:
c - Closure to convert.
Returns:
Closure converted to predicate.

as

public static <T> GridPredicate<T> as(GridClosure<? super T,Boolean> c)
Converts given closure to predicate.

Parameters:
c - Closure to convert.
Returns:
Closure converted to predicate.

as

public static <T1,T2> GridPredicate2<T1,T2> as(GridClosure2<? super T1,? super T2,Boolean> c)
Converts given closure to predicate.

Parameters:
c - Closure to convert.
Returns:
Closure converted to predicate.

as

public static <T1,T2,T3> GridPredicate3<T1,T2,T3> as(GridClosure3<? super T1,? super T2,? super T3,Boolean> c)
Converts given closure to predicate.

Parameters:
c - Closure to convert.
Returns:
Closure converted to predicate.

as

public static GridOutClosure<Boolean> as(GridAbsPredicate p)
Converts given predicate to closure.

Parameters:
p - Predicate to convert.
Returns:
Predicate converted to closure.

as

public static <X> GridClosure<X,Boolean> as(GridPredicate<? super X> p)
Converts given predicate to closure.

Type Parameters:
X - Type of the free variable for the predicate.
Parameters:
p - Predicate to convert.
Returns:
Predicate converted to closure.

as

public static <X1,X2> GridClosure2<X1,X2,Boolean> as(GridPredicate2<? super X1,? super X2> p)
Converts given predicate to closure.

Type Parameters:
X1 - Type of the free variable for the predicate.
X2 - Type of the free variable for the predicate.
Parameters:
p - Predicate to convert.
Returns:
Predicate converted to closure.

as

public static <X1,X2,X3> GridClosure3<X1,X2,X3,Boolean> as(GridPredicate3<? super X1,? super X2,? super X3> p)
Converts given predicate to closure.

Type Parameters:
X1 - Type of the free variable for the predicate.
X2 - Type of the free variable for the predicate.
X3 - Type of the free variable for the predicate.
Parameters:
p - Predicate to convert.
Returns:
Predicate converted to closure.

compose

public static <D,B,C> GridClosure<D,C> compose(GridClosure<? super D,? extends B> f,
                                               GridClosure<? super B,C> g)
Composes two closures into one. If a is a free variable the result closure is g.apply(f.apply(a)). Note that both closures must be loaded by the same class loader.

Type Parameters:
D - Type of the free variable for the closure.
B - Type of return value and of the free variable for the closure.
C - Type of the return value for the closure.
Parameters:
f - First closure.
g - Second closure.
Returns:
Composition closure.

forMap

public static <K,V> GridClosure<K,V> forMap(Map<? extends K,? extends V> m)
Gets closure that wraps given map access, i.e. returns map's value assuming that free variable is a map's key.

Type Parameters:
K - Type of the free variable for the closure and type of the map keys.
V - Type of the closure's return value and type of the map values.
Parameters:
m - Source map.
Returns:
Closure that wraps given map access.

forMap

public static <K,V> GridClosure<K,V> forMap(Map<? extends K,? extends V> m,
                                            @Nullable
                                            Callable<V> c)
Gets closure that wraps given map's access, i.e. returns map's value assuming that free variable is a map's key or default value produced by optional factory closure if key has no mapping.

Type Parameters:
K - Type of the free variable for the closure and type of the map keys.
V - Type of the closure's return value and type of the map values.
Parameters:
m - Source map.
c - Optional factory closure to produce default value to return from result closure if key has no mapping in given map. If factory closure is null - the default value will be null.
Returns:
Closure that wraps given map's access.

string

public static <T> GridClosure<T,String> string()
Gets closure that return toString() value for its free variable.

Type Parameters:
T - Type of the free variable for the closure.
Returns:
Closure that return toString() value for its free variable.

in

public static <T> GridPredicate<T> in(@Nullable
                                      Collection<? extends T> c)
Gets predicate that returns true if its free variable is contained in given collection.

Type Parameters:
T - Type of the free variable for the predicate and type of the collection elements.
Parameters:
c - Collection to check for containment.
Returns:
Predicate that returns true if its free variable is contained in given collection.

notIn

public static <T> GridPredicate<T> notIn(@Nullable
                                         Collection<? extends T> c)
Gets predicate that returns true if its free variable is not contained in given collection.

Type Parameters:
T - Type of the free variable for the predicate and type of the collection elements.
Parameters:
c - Collection to check for containment.
Returns:
Predicate that returns true if its free variable is not contained in given collection.

addIfAbsent

@Nullable
public static <K,V> V addIfAbsent(ConcurrentMap<K,V> map,
                                           K key,
                                           @Nullable
                                           Callable<V> c)
Gets the value with given key. If that value does not exist, calls given closure to get the default value, puts it into the map and returns it. If closure is null return null.

Type Parameters:
K - Key type.
V - Value type.
Parameters:
map - Concurrent hash map.
key - Key to get the value for.
c - Default value producing closure.
Returns:
Value for the key or the value produced by the closure if key does not exist in the map. Return null if key is not found and closure is null.

addIfAbsent

public static <K,V> V addIfAbsent(ConcurrentMap<K,V> map,
                                  K key,
                                  V val)
Gets the value with given key. If that value does not exist, puts given value into the map and returns it.

Type Parameters:
K - Key type.
V - Value type.
Parameters:
map - Map.
key - Key.
val - Value to put if one does not exist.
Returns:
Current mapping for a given key.

addIfAbsent

@Nullable
public static <K,V> V addIfAbsent(Map<K,V> map,
                                           @Nullable
                                           K key,
                                           @Nullable
                                           Callable<V> c)
Utility map getter.

Throws:
GridClosureException - Thrown in case when callable throws exception.
Type Parameters:
K - Map key type.
V - Map value type.
Parameters:
map - Map to get value from.
key - Map key (can be null).
c - Optional factory closure for the default value to be put in when key is not found. If closure is not provided - null will be put into the map.
Returns:
Value for the key or default value produced by c if key is not found (or null if key is not found and closure is not provided). Note that in case when key is not found the default value will be put into the map.
See Also:
GridFunc.newLinkedList(), GridFunc.newList(), GridFunc.newSet(), GridFunc.newMap(), GridFunc.newAtomicLong(), GridFunc.newAtomicInt(), GridFunc.newAtomicRef(), GridFunc.newAtomicBoolean()

addIfAbsent

@Nullable
public static <K,V> V addIfAbsent(Map<K,V> map,
                                           @Nullable
                                           K key,
                                           @Nullable
                                           V v)
Utility map getter.

Type Parameters:
K - Map key type.
V - Map value type.
Parameters:
map - Map to get value from.
key - Map key (can be null).
v - Optional value to be put in when key is not found. If not provided - null will be put into the map.
Returns:
Value for the key or default value c if key is not found (or null if key is not found and value is not provided). Note that in case when key is not found the default value will be put into the map.

in

public static <T> GridPredicate<T> in(@Nullable
                                      T[] c)
Gets predicate that returns true if its free variable is contained in given array.

Type Parameters:
T - Type of the free variable for the predicate and type of the array elements.
Parameters:
c - Array to check for containment.
Returns:
Predicate that returns true if its free variable is contained in given array.

notIn

public static <T> GridPredicate<T> notIn(@Nullable
                                         T[] c)
Gets predicate that returns true if its free variable is not contained in given array.

Type Parameters:
T - Type of the free variable for the predicate and type of the array elements.
Parameters:
c - Array to check for containment.
Returns:
Predicate that returns true if its free variable is not contained in given array.

reduce

public static <X,Y> Y reduce(Iterable<? extends X> c,
                             GridReducer<? super X,Y> f)
Reduces collection into single value using given for-all closure.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Y - Type of the closure's return value.
Parameters:
c - Collection to reduce.
f - For-all closure used for reduction.
Returns:
Single value as a result of collection reduction.

reduce

@Nullable
public static <X,Y,R> R reduce(Map<? extends X,? extends Y> m,
                                        GridReducer2<? super X,? super Y,R> f)
Reduces given map into single value using given for-all closure.

Type Parameters:
X - Type of the free variable for the closure and type of the map keys.
Y - Type of the closure's return value and type of the map values.
R - Type of the return value for the closure.
Parameters:
m - Map to reduce.
f - For-all closure used for reduction.
Returns:
Single value as a result of map reduction.

forEach

public static <X> void forEach(Iterable<? extends X> c,
                               GridInClosure<? super X> f,
                               @Nullable
                               GridPredicate<? super X>... p)
Calls given side-effect only closure over the each element of the provided collection.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Parameters:
c - Collection to call closure over.
f - Side-effect only closure to call over the collection.
p - Optional set of predicates. Only if collection element evaluates to true for given predicates the closure will be applied to it. If no predicates provided - closure will be applied to all collection elements.

forEach

public static <X> void forEach(X[] c,
                               GridInClosure<? super X> f,
                               @Nullable
                               GridPredicate<? super X>... p)
Calls given side-effect only closure over the each element of the provided array.

Type Parameters:
X - Type of the free variable for the closure and type of the array elements.
Parameters:
c - Array to call closure over.
f - Side-effect only closure to call over the array.
p - Optional set of predicates. Only if collection element evaluates to true for given predicates the closure will be applied to it. If no predicates provided - closure will be applied to all collection elements.

metaEntry

public static <T extends GridMetadataAware> GridPredicate<T> metaEntry(@Nullable
                                                                       Map.Entry<String,?>... meta)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.

Type Parameters:
T - Type of returned predicate.
Parameters:
meta - Collection of metadata.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
See Also:
GridFunc.meta(String...), GridFunc.meta(Iterable), GridFunc.meta(String, Object)

metaEntry

public static <T extends GridMetadataAware> GridPredicate<T> metaEntry(@Nullable
                                                                       Collection<? extends Map.Entry<String,?>> meta)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.

Type Parameters:
T - Type of returned predicate.
Parameters:
meta - Collection of metadata.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
See Also:
GridFunc.meta(String...), GridFunc.meta(Iterable), GridFunc.meta(String, Object)

meta

public static <T extends GridMetadataAware> GridPredicate<T> meta(@Nullable
                                                                  Map<String,?> meta)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.

Type Parameters:
T - Type of returned predicate.
Parameters:
meta - Collection of metadata as a map.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains all provided metadata.
See Also:
GridFunc.meta(String...), GridFunc.meta(Iterable), GridFunc.meta(String, Object), GridFunc.metaEntry(java.util.Map.Entry[]), GridFunc.metaEntry(Collection)

meta

public static <T extends GridMetadataAware> GridPredicate<T> meta(String name,
                                                                  Object val)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata.

Type Parameters:
T - Type of returned predicate.
Parameters:
name - Metadata name.
val - Metadata value.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata.
See Also:
GridFunc.metaEntry(java.util.Map.Entry[]), GridFunc.meta(String...), GridFunc.meta(Iterable)

meta

public static <T extends GridMetadataAware> GridPredicate<T> meta(@Nullable
                                                                  String... names)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).

Type Parameters:
T - Type of returned predicate.
Parameters:
names - Metadata names to evaluate by.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).

meta

public static <T extends GridMetadataAware> GridPredicate<T> meta(@Nullable
                                                                  Iterable<String> names)
Creates predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).

Type Parameters:
T - Type of returned predicate.
Parameters:
names - Metadata names to evaluate by.
Returns:
Predicate that accepts subclass of GridMetadataAware interface and evaluates to true if it contains given metadata names (values are ignored).

copy

public static <T> Collection<T> copy(Collection<T> to,
                                     T... from)
Adds (copies) to given collection all elements in 'from' array.

Type Parameters:
T - Type of the free variable for the predicate and type of the collection elements.
Parameters:
to - Collection to copy to.
from - Array to copy from.
Returns:
Collection to copy to.

copy

public static <T> Collection<T> copy(Collection<T> to,
                                     Iterable<? extends T> from,
                                     @Nullable
                                     GridPredicate<? super T>... p)
Adds (copies) to given collection using provided predicates. Element is copied if all predicates evaluate to true.

Type Parameters:
T - Type of the free variable for the predicate and type of the collection elements.
Parameters:
to - Collection to copy to.
from - Collection to copy from.
p - Optional set of predicates to use for filtration.
Returns:
Collection to copy to.

transform

public static <X,Y> Collection<Y> transform(Collection<Y> to,
                                            Iterable<? extends X> from,
                                            GridClosure<? super X,Y> f,
                                            @Nullable
                                            GridPredicate<? super X>... p)
Transforms one collection to another using provided closure and predicate. Value from the initial collection will be transformed only if all predicates evaluate to true for this value. Note that no new collection will be created.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Y - Type of the closure's return value.
Parameters:
to - Destination collection to transform to.
from - Initial collection to transform.
f - Closure to use for transformation.
p - Optional predicates to use for transformation.
Returns:
Destination collection.

forEach

public static <K,V> void forEach(Map<? extends K,? extends V> m,
                                 GridInClosure<? super GridTuple2<K,V>> f,
                                 @Nullable
                                 GridPredicate<? super GridTuple2<K,V>>... p)
Calls given side-effect only closure (if provided) over the each element of the provided map. If provided closure is null this method is no-op.

Type Parameters:
K - Type of the free variable for the closure and type of the map keys.
V - Type of the closure's return value and type of the map values.
Parameters:
m - Map to call closure over.
f - Optional closure to call over the map.
p - Optional set of predicates. Only if map entry evaluates to true for given predicates the closure will be applied to it. If no predicates provided - closure will be applied to all map entries.

transform

public static <X,Y> Collection<Y> transform(Collection<? extends X> c,
                                            GridClosure<? super X,Y> f)
Transforms one collection to another using provided closure. New collection will be created.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Y - Type of the closure's return value.
Parameters:
c - Initial collection to transform.
f - Closure to use for transformation.
Returns:
Transformed newly created collection.

upcast

public static <X,Y extends X> Collection<Y> upcast(Collection<? extends X> c,
                                                   GridClosure<? super X,Y> f)
Special version of transform method that works on two types that are in child-parent relationship. It allows for optimization when the input collection is implementation of List interfaces. In such case no new collection will be created and transformation will happen in place.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Y - Type of the closure's return value.
Parameters:
c - Initial collection to transform.
f - Closure to use for transformation.
Returns:
Transformed collection. In case of input collection implementing List interface transformation done in place and original collection is returned.

transform

public static <X,Y> Collection<Y> transform(X[] c,
                                            GridClosure<? super X,Y> f)
Transforms an array to read only collection using provided closure.

Type Parameters:
X - Type of the free variable for the closure and type of the array elements.
Y - Type of the closure's return value.
Parameters:
c - Initial array to transform.
f - Closure to use for transformation.
Returns:
Transformed read only collection.

isAll

public static <T> boolean isAll(@Nullable
                                T t,
                                @Nullable
                                GridPredicate<? super T>... p)
Tests if all provided predicates evaluate to true for given value. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
T - Type of the value and free variable of the predicates.
Parameters:
t - Value to test.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if given set of predicates is null, is empty, or all predicates evaluate to true for given value, false otherwise.

isAll

public static <T> boolean isAll(@Nullable
                                T t,
                                @Nullable
                                Iterable<? extends GridPredicate<? super T>> p)
Tests if all provided predicates evaluate to true for given value. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
T - Type of the value and free variable of the predicates.
Parameters:
t - Value to test.
p - Optional set of predicates to use for evaluation.
Returns:
Returns true if given set of predicates is null, is empty, or all predicates evaluate to true for given value, false otherwise.

isAll2

public static <A,B> boolean isAll2(@Nullable
                                   A a,
                                   @Nullable
                                   B b,
                                   @Nullable
                                   GridPredicate2<? super A,? super B> p)
Tests if all provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if all predicates evaluate to true for given values, false otherwise.

isAll2

public static <A,B> boolean isAll2(@Nullable
                                   A a,
                                   @Nullable
                                   B b,
                                   @Nullable
                                   GridPredicate2<? super A,? super B>[] p)
Tests if all provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if all predicates evaluate to true for given values, false otherwise.

isAll2

public static <A,B> boolean isAll2(@Nullable
                                   A a,
                                   @Nullable
                                   B b,
                                   @Nullable
                                   Iterable<? extends GridPredicate2<? super A,? super B>> p)
Tests if all provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if all predicates evaluate to true for given values, false otherwise.

isAll3

public static <A,B,C> boolean isAll3(@Nullable
                                     A a,
                                     @Nullable
                                     B b,
                                     @Nullable
                                     C c,
                                     @Nullable
                                     GridPredicate3<? super A,? super B,? super C>... p)
Tests if all provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
C - Type of the 3d value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
c - 3d value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if all predicates evaluate to true for given values, false otherwise.

isAll3

public static <A,B,C> boolean isAll3(@Nullable
                                     A a,
                                     @Nullable
                                     B b,
                                     @Nullable
                                     C c,
                                     @Nullable
                                     Iterable<? extends GridPredicate3<? super A,? super B,? super C>> p)
Tests if all provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to false is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
C - Type of the 3d value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
c - 3d value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return true.
Returns:
Returns true if all predicates evaluate to true for given values, false otherwise.

isAny

public static <T> boolean isAny(@Nullable
                                T t,
                                @Nullable
                                GridPredicate<? super T>... p)
Tests if any of provided predicates evaluate to true for given value. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
T - Type of the value and free variable of the predicates.
Parameters:
t - Value to test.
p - Optional set of predicates to use for evaluation.
Returns:
Returns true if any of predicates evaluates to true for given value, false otherwise. Returns false if given set of predicates is null or empty.

isAny

public static <T> boolean isAny(@Nullable
                                T t,
                                @Nullable
                                Iterable<? extends GridPredicate<? super T>> p)
Tests if any of provided predicates evaluate to true for given value. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
T - Type of the value and free variable of the predicates.
Parameters:
t - Value to test.
p - Optional set of predicates to use for evaluation.
Returns:
Returns true if any of predicates evaluates to true for given value, false otherwise. Returns false if given set of predicates is null or empty.

isAny2

public static <A,B> boolean isAny2(@Nullable
                                   A a,
                                   @Nullable
                                   B b,
                                   @Nullable
                                   GridPredicate2<? super A,? super B>... p)
Tests if any of provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return false.
Returns:
Returns true if any of predicates evaluate to true for given values, false otherwise.

isAny2

public static <A,B> boolean isAny2(@Nullable
                                   A a,
                                   @Nullable
                                   B b,
                                   @Nullable
                                   Iterable<? extends GridPredicate2<? super A,? super B>> p)
Tests if any of provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return false.
Returns:
Returns true if any of predicates evaluate to true for given values, false otherwise.

isAny3

public static <A,B,C> boolean isAny3(@Nullable
                                     A a,
                                     @Nullable
                                     B b,
                                     @Nullable
                                     C c,
                                     @Nullable
                                     GridPredicate3<? super A,? super B,? super C>... p)
Tests if any of provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
C - Type of the 3d value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
c - 3d value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return false.
Returns:
Returns true if any of predicates evaluate to true for given values, false otherwise.

isAny3

public static <A,B,C> boolean isAny3(@Nullable
                                     A a,
                                     @Nullable
                                     B b,
                                     @Nullable
                                     C c,
                                     @Nullable
                                     Iterable<? extends GridPredicate3<? super A,? super B,? super C>> p)
Tests if any of provided predicates evaluate to true for given values. Note that evaluation will be short-circuit when first predicate evaluated to true is found.

Type Parameters:
A - Type of the 1st value for the predicates.
B - Type of the 2nd value for the predicates.
C - Type of the 3d value for the predicates.
Parameters:
a - 1st value for predicate.
b - 2nd value for predicate.
c - 3d value for predicate.
p - Optional set of predicates to use for evaluation. If no predicates provides this method will always return false.
Returns:
Returns true if any of predicates evaluate to true for given values, false otherwise.

transform

public static <X,Y> Collection<Y> transform(Collection<? extends X> c,
                                            GridClosure<? super X,Y> f,
                                            GridPredicate<? super X>... p)
Transforms one collection to another using provided closure and optional set of predicates. Value from the initial collection will be transformed only if all predicates evaluate to true for this value. Note that new collection will be created.

Type Parameters:
X - Type of the free variable for the closure and type of the collection elements.
Y - Type of the closure's return value.
Parameters:
c - Initial collection to transform.
f - Closure to use for transformation.
p - Optional set of predicate to use for transformation.
Returns:
Transformed newly created collection.

limit

public static GridAbsPredicate limit(int n)
Gets absolute (no-arg) predicate that returns true first n-times it's called - and false thereafter.

Parameters:
n - Number of calls this predicate will return true.
Returns:
Predicate that returns true first n-times it's called - and false thereafter.

noop

public static GridAbsClosure noop()
Creates an absolute (no-arg) closure that does nothing.

Returns:
Absolute (no-arg) closure that does nothing.

or

public static <D,B> GridPredicate2<D,B> or(GridPredicate<? super D> pa,
                                           GridPredicate<? super B> pb)
Gets OR-composition predicate out of two provided predicates. Result predicate evaluates to true if either one of the provided predicates evaluates to true. Note that evaluation will be "short-circuit" if first predicate evaluate to true.

Note tha both predicates must be loaded by the same class loader.

Type Parameters:
D - Type of the free variable for the first predicate.
B - Type of the free variable for the second predicate
Parameters:
pa - First predicate to compose of.
pb - Second predicate to compose of.
Returns:
OR-composition predicate.

find

@Nullable
public static <V> V find(Iterable<? extends V> c,
                                  @Nullable
                                  V dfltVal,
                                  @Nullable
                                  GridPredicate<? super V>... p)
Finds and returns first element in given collection for which any of the provided predicates evaluates to true.

Type Parameters:
V - Type of the collection elements.
Parameters:
c - Input collection.
dfltVal - Default value to return when no element is found.
p - Optional set of finder predicates.
Returns:
First element in given collection for which predicate evaluates to true - or null if such element cannot be found.

find

@Nullable
public static <V> V find(V[] c,
                                  V dfltVal,
                                  @Nullable
                                  GridPredicate<? super V>... p)
Finds and returns first element in given array for which any of the provided predicates evaluates to true.

Type Parameters:
V - Type of the array elements.
Parameters:
c - Input array.
dfltVal - Default value to return when no element is found.
p - Optional set of finder predicates.
Returns:
First element in given array for which predicate evaluates to true - or null if such element cannot be found.

find

public static <V,Y> Y find(Iterable<? extends V> c,
                           Y dfltVal,
                           GridClosure<? super V,Y> f,
                           @Nullable
                           GridPredicate<? super V>... p)
Finds, transforms and returns first element in given collection for which any of the provided predicates evaluates to true.

Type Parameters:
V - Type of the collection elements.
Parameters:
c - Input collection.
dfltVal - Default value to return when no element is found.
f - Transforming closure.
p - Optional set of finder predicates.
Returns:
First element in given collection for which predicate evaluates to true - or null if such element cannot be found.

find

public static <V,Y> Y find(V[] c,
                           Y dfltVal,
                           GridClosure<? super V,Y> f,
                           @Nullable
                           GridPredicate<? super V>... p)
Finds, transforms and returns first element in given array for which any of the provided predicates evaluates to true.

Type Parameters:
V - Type of the array elements.
Parameters:
c - Input array.
dfltVal - Default value to return when no element is found.
f - Transforming closure.
p - Optional set of finder predicates.
Returns:
First element in given collection for which predicate evaluates to true - or null if such element cannot be found.

containsAny

public static <T> boolean containsAny(@Nullable
                                      Collection<? extends T> c1,
                                      @Nullable
                                      Iterable<? extends T> c2)
Checks if collection c1 contains any elements from collection c2.

Type Parameters:
T - Type of the elements.
Parameters:
c1 - Collection to check for containment. If null - this method returns false.
c2 - Collection of elements to check. If null - this method returns false.
Returns:
true if collection c1 contains at least one element from collection c2.

containsAny

public static <T> boolean containsAny(@Nullable
                                      Collection<? extends T> c1,
                                      @Nullable
                                      T... c2)
Checks if collection c1 contains any elements from array c2.

Type Parameters:
T - Type of the elements.
Parameters:
c1 - Collection to check for containment. If null - this method returns false.
c2 - Collection of elements to check. If null - this method returns false.
Returns:
true if collection c1 contains at least one element from collection c2.

containsAll

public static <T> boolean containsAll(@Nullable
                                      Collection<? extends T> c1,
                                      @Nullable
                                      Iterable<? extends T> c2)
Checks if collection c1 contains all elements from collection c2.

Type Parameters:
T - Type of the elements.
Parameters:
c1 - Collection to check for containment. If null - this method returns false.
c2 - Collection of elements to check. If null - this method returns true meaning that null-collection is treated as empty collection.
Returns:
true if collection c1 contains all elements from collection c2.

split

public static <T0,T extends T0> GridPair<Collection<T>> split(@Nullable
                                                              Collection<T> c,
                                                              @Nullable
                                                              GridPredicate<? super T>... p)
Splits given collection in two using provided set of predicates.

Type Parameters:
T - Type of the collection.
Parameters:
c - Collection to split. If null - pair of nulls will be returned. If it's empty - pair of empty collections will be returned.
p - Optional filter. All elements that satisfy all provided predicates will go into 1st collection in pair. The rest will be in 2nd collection. If not provided, pair of original and empty collection will be returned.
Returns:
Pair of two collections.

pair

public static <T> GridPair<T> pair(@Nullable
                                   T t1,
                                   @Nullable
                                   T t2)
Creates pair out of given two objects.

Type Parameters:
T - Type of objects in pair.
Parameters:
t1 - First object in pair.
t2 - Second object in pair.
Returns:
Pair of objects.

triple

public static <T> GridTriple<T> triple(@Nullable
                                       T t1,
                                       @Nullable
                                       T t2,
                                       @Nullable
                                       T t3)
Creates triple out of given three objects.

Type Parameters:
T - Type of objects in triple.
Parameters:
t1 - First object in triple.
t2 - Second object in triple.
t3 - Third object in triple.
Returns:
Triple of objects.

partition

public static <V> GridTuple2<Collection<V>,Collection<V>> partition(Iterable<? extends V> c,
                                                                    GridPredicate<? super V> p)
Partitions input collection in two: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.

Type Parameters:
V - Type of the collection elements.
Parameters:
c - Input collection.
p - Partitioning predicate.
Returns:
Tuple of two collections: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.

partition

public static <V> GridTuple2<Collection<V>,Collection<V>> partition(V[] c,
                                                                    GridPredicate<? super V> p)
Partitions input array in two: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.

Type Parameters:
V - Type of the array elements.
Parameters:
c - Input array.
p - Partitioning predicate.
Returns:
Tuple of two collections: first containing elements for which given predicate evaluates to true - and second containing the elements for which predicate evaluates to false.

partition

public static <K,V> GridTuple2<Map<K,V>,Map<K,V>> partition(Map<? extends K,? extends V> m,
                                                            GridPredicate2<? super K,? super V> p)
Partitions input map in two: first containing entries for which given predicate evaluates to true - and second containing the entries for which predicate evaluates to false.

Type Parameters:
K - Type of the map keys.
V - Type of the map values.
Parameters:
m - Input map.
p - Partitioning predicate.
Returns:
Tuple of two maps: first containing entries for which given predicate evaluates to true - and second containing the entries for which predicate evaluates to false.

exist

public static <V> boolean exist(Iterable<? extends V> c,
                                @Nullable
                                GridPredicate<? super V>... p)
Checks for existence of the element in input collection for which all provided predicates evaluate to true.

Type Parameters:
V - Type of the collection elements.
Parameters:
c - Input collection.
p - Optional set of checking predicates.
Returns:
true if input collection contains element for which all the provided predicates evaluates to true - otherwise returns false.

exist

public static <V> boolean exist(V[] c,
                                @Nullable
                                GridPredicate<? super V