Class GridFunc

  • Direct Known Subclasses:
    F

    public class GridFunc
    extends Object
    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:

    • Factory higher-order methods for closures, predicates and tuples, and
    • Utility higher-order methods for processing collections with closures and predicates.
    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.

    Also note, that in all methods with predicates, null predicate has a true meaning. So does the empty predicate array.

    • Constructor Detail

      • GridFunc

        public GridFunc()
    • Method Detail

      • localNode

        public static <T extends ClusterNodeIgnitePredicate<T> localNode​(UUID locNodeId)
        Gets predicate that evaluates to true only for given local node ID.
        Type Parameters:
        T - Type of the node.
        Parameters:
        locNodeId - Local node ID.
        Returns:
        Return true only for the node with given local node ID.
      • remoteNodes

        public static <T extends ClusterNodeIgnitePredicate<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.
      • dedup

        @Deprecated
        public static <T> Collection<T> dedup​(Collection<? extends T> c)
        Deprecated.
        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.
      • sumInt

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

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

        @Deprecated
        public static IgniteReducer<Integer,​Integer> sumIntReducer()
        Deprecated.
        Gets reducer closure that calculates sum of integer elements.

        Returns:
        Reducer that calculates sum of integer elements.
      • sumLongReducer

        @Deprecated
        public static IgniteReducer<Long,​Long> sumLongReducer()
        Deprecated.
        Gets reducer closure that calculates sum of long integer elements.

        Returns:
        Reducer that calculates sum of long integer elements.
      • range

        @Deprecated
        public static List<Integer> range​(int fromIncl,
                                          int toExcl)
        Deprecated.
        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.
      • concat

        public static String concat​(Iterable<?> c,
                                    @Nullable
                                    @Nullable String delim)
        Concatenates strings using provided delimiter.
        Parameters:
        c - Input collection.
        delim - Delimiter (optional).
        Returns:
        Concatenated string.
      • nodeIds

        public static Collection<UUID> nodeIds​(@Nullable
                                               @Nullable Collection<? extends ClusterNode> 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.
      • nodeConsistentIds

        public static Collection<Object> nodeConsistentIds​(@Nullable
                                                           @Nullable Collection<? extends BaselineNode> nodes)
        Convenient utility method that returns collection of node consistent 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 consistent IDs for given collection of grid nodes.
      • 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 (no null and not emtpy).
        Returns:
        Random value from the input collection.
      • rand

        @Deprecated
        public static <T> T rand​(List<T> l)
        Deprecated.
        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

        @Deprecated
        public static <T> T rand​(T... c)
        Deprecated.
        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 cp,
                                               @Nullable
                                               T t,
                                               @Nullable
                                               @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:
        cp - Copy flag.
        t - First element.
        c - Second collection.
        Returns:
        Concatenated collection.
      • concat

        public static <T> Collection<T> concat​(boolean cp,
                                               @Nullable
                                               @Nullable Collection<T> c1,
                                               @Nullable
                                               @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:
        cp - Copy flag.
        c1 - First collection.
        c2 - Second collection.
        Returns:
        Concatenated non-null collection.
      • concat

        public static <T> T[] concat​(@Nullable
                                     @Nullable T[] arr,
                                     T... obj)
        Concatenates an elements to an array.
        Parameters:
        arr - Array.
        obj - One or more elements.
        Returns:
        Concatenated array.
      • concat

        public static <T> Iterator<T> concat​(Iterator<T>... iters)
        Concatenates multiple iterators as single one.
        Parameters:
        iters - Iterators.
        Returns:
        Single iterator.
      • concat

        public static <T> Iterator<T> concat​(Iterator<Iterator<T>> iters)
        Concatenates multiple iterators as single one.
        Parameters:
        iters - Iterator over iterators.
        Returns:
        Single iterator.
      • lose

        public static <T0,​T extends T0> Collection<T> lose​(Collection<T> c,
                                                                 boolean cp,
                                                                 @Nullable
                                                                 @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.
        cp - 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

        @Deprecated
        public static <T> Collection<T> lose​(Collection<T> c,
                                             boolean cp,
                                             @Nullable
                                             @Nullable IgnitePredicate<? super T>... p)
        Deprecated.
        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.
        cp - 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

        @Deprecated
        public static <K,​V> Map<K,​V> lose​(Map<K,​V> m,
                                                      boolean cp,
                                                      @Nullable
                                                      @Nullable IgnitePredicate<? super Map.Entry<K,​V>>... p)
        Deprecated.
        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.
        cp - 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.
      • loseList

        public static <T> List<T> loseList​(List<T> c,
                                           boolean cp,
                                           @Nullable
                                           @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.
        cp - 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
      • filterList

        @Deprecated
        public static <T> List<T> filterList​(List<T> c,
                                             boolean cp,
                                             @Nullable
                                             @Nullable IgnitePredicate<T>... p)
        Deprecated.
        Loses all elements in input list for which any of the predicates evaluate to true.
        Type Parameters:
        T - Type of list.
        Parameters:
        c - Input list.
        cp - If true method creates new list not modifying input, otherwise does in-place modifications.
        p - Looses all elements for which any of the predicates evaluate to true.
        Returns:
        List of remaining elements
      • node2id

        public static IgniteClosure<? super ClusterNode,​UUID> node2id()
        Gets closure which converts node to node ID.
        Returns:
        Closure which converts node to node ID.
      • nodeForNodeId

        public static <T extends ClusterNodeIgnitePredicate<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:
        idForNodeId(UUID), nodeIds(Collection)
      • nodeForNodes

        public static IgnitePredicate<ClusterNode> nodeForNodes​(ClusterNode... 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

        @Deprecated
        public static <T0,​T extends T0> Collection<T> retain​(Collection<T> c,
                                                                   boolean cp,
                                                                   @Nullable
                                                                   @Nullable Collection<? extends T0> filter)
        Deprecated.
        Retains all elements in input collection that are contained in filter.
        Type Parameters:
        T - Type of collections.
        Parameters:
        c - Input collection.
        cp - 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 cp,
                                               @Nullable
                                               @Nullable IgnitePredicate<? 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.
        cp - 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 cp,
                                               int num)
        Retains only up to first num elements in the input collection.
        Type Parameters:
        T - Type of the collections.
        Parameters:
        c - Input collection.
        cp - 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.
      • asList

        public static <T> List<T> asList​(@Nullable
                                         @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

        @Deprecated
        public static <T> GridIterator<T> emptyIterator()
        Deprecated.
        Creates new empty iterator.
        Type Parameters:
        T - Type of the iterator.
        Returns:
        Newly created empty iterator.
      • flatCollections

        public static <T> Collection<T> flatCollections​(@Nullable
                                                        @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
                                               @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.
      • flatIterators

        public static <T> Iterator<T> flatIterators​(@Nullable
                                                    @Nullable Iterable<Iterator<T>> c)
        Flattens iterable-of-iterators and returns iterator over the elements of the inner collections. This method doesn't create any new collections or copies any elements.
        Parameters:
        c - Input iterable of iterators.
        Returns:
        Iterator over the elements of given iterators.
      • as

        @Deprecated
        public static GridAbsClosure as​(@Nullable
                                        @Nullable Runnable r)
        Deprecated.
        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.
      • size

        public static <T> int size​(@Nullable
                                   @Nullable Collection<? extends T> c,
                                   @Nullable
                                   @Nullable IgnitePredicate<? 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
                                   @Nullable Iterator<? extends T> it,
                                   @Nullable
                                   @Nullable IgnitePredicate<? 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

        @SafeVarargs
        public static <T> Collection<T> view​(@Nullable
                                             @Nullable Collection<T> c,
                                             @Nullable
                                             @Nullable IgnitePredicate<? 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 predicates, if any, evaluate 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 predicates. If predicates are not provided - all elements will be in the view.
        Returns:
        Light-weight view on given collection with provided predicate.
      • viewReadOnly

        @SafeVarargs
        public static <T1,​T2> Collection<T2> viewReadOnly​(@Nullable
                                                                @Nullable Collection<? extends T1> c,
                                                                IgniteClosure<? super T1,​T2> trans,
                                                                @Nullable
                                                                @Nullable IgnitePredicate<? 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.
      • transformList

        @Deprecated
        public static <T1,​T2> List<T2> transformList​(Collection<? extends T1> c,
                                                           IgniteClosure<? super T1,​T2> trans,
                                                           @Nullable
                                                           @Nullable IgnitePredicate<? super T1>... p)
        Deprecated.
        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.
      • view

        public static <K0,​K extends K0,​V0,​V extends V0> Map<K,​V> view​(@Nullable
                                                                                              @Nullable Map<K,​V> m,
                                                                                              @Nullable
                                                                                              @Nullable IgnitePredicate<? 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
                                                                                                                @Nullable Map<K,​V> m,
                                                                                                                IgniteClosure<V,​V1> trans,
                                                                                                                @Nullable
                                                                                                                @Nullable IgnitePredicate<? 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.
      • viewReadOnly

        @Deprecated
        public static <K0,​K extends K0,​V0,​V extends V0,​V1> Map<K,​V1> viewReadOnly​(@Nullable
                                                                                                                @Nullable Map<K,​V> m,
                                                                                                                IgniteBiClosure<K,​V,​V1> trans,
                                                                                                                @Nullable
                                                                                                                @Nullable IgnitePredicate<? super K>... p)
        Deprecated.
        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.
      • viewAsMap

        public static <K0,​K extends K0,​V0,​V extends V0> Map<K,​V> viewAsMap​(@Nullable
                                                                                                   @Nullable Set<K> c,
                                                                                                   IgniteClosure<? super K,​V> mapClo,
                                                                                                   @Nullable
                                                                                                   @Nullable IgnitePredicate<? super K>... p)
        Read-only map view of a collection. Resulting map is a lightweight view of an input collection, with filtered elements of an input collection as keys, and closure execution results as values. The map will only contain keys for which all provided predicates, if any, evaluate 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 - Key type.
        V - Value type.
        Parameters:
        c - Input collection.
        mapClo - Mapping closure, that maps key to value.
        p - Optional predicates to filter input collection. If predicates are not provided - all elements will be in the view.
        Returns:
        Light-weight view on given map with provided predicates and mapping.
      • isEmpty

        public static boolean isEmpty​(@Nullable
                                      @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
                                          @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.
      • isEmptyOrNulls

        public static <T> boolean isEmptyOrNulls​(@Nullable
                                                 @Nullable T[] c)
        Tests if the given array is null, empty or contains only null values.
        Parameters:
        c - Array to test.
        Returns:
        Whether or not the given array is null, empty or contains only null values.
      • isEmpty

        public static boolean isEmpty​(@Nullable
                                      @org.jetbrains.annotations.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
                                      @org.jetbrains.annotations.Nullable byte[] 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
                                      @org.jetbrains.annotations.Nullable long[] 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
                                      @org.jetbrains.annotations.Nullable char[] 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
                                      @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
                                      @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
                                      @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.
      • isEmptyDirectory

        public static boolean isEmptyDirectory​(Path dir)
        Tests if the given path is not null and is an empty directory.
        Parameters:
        dir - Path to test.
        Returns:
        Whether or not the given path is not null and is an empty directory.
      • isNotEmptyDirectory

        public static boolean isNotEmptyDirectory​(Path dir)
        Tests if the given path is not null and is a not empty directory.
        Parameters:
        dir - Path to test.
        Returns:
        Whether or not the given path is not null and is a not empty directory.
      • newSet

        public static <T> IgniteCallable<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 IgniteOutClosure.apply() method is called.
      • newMap

        @Deprecated
        public static <K,​V> IgniteCallable<Map<K,​V>> newMap()
        Deprecated.
        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 IgniteOutClosure.apply() method is called.
      • iterator0

        public static <T> GridIterator<T> iterator0​(Iterable<? extends T> c,
                                                    boolean readOnly,
                                                    IgnitePredicate<? 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​(Iterable<? extends T1> c,
                                                              IgniteClosure<? super T1,​T2> trans,
                                                              boolean readOnly,
                                                              @Nullable
                                                              @Nullable IgnitePredicate<? 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.
      • iterator

        @SafeVarargs
        public static <T1,​T2> Iterator<T2> iterator​(Iterator<? extends T1> c,
                                                          IgniteClosure<? super T1,​T2> trans,
                                                          boolean readOnly,
                                                          @Nullable
                                                          @Nullable IgnitePredicate<? super T1>... p)
        Parameters:
        c - Input iterator.
        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 iterator and optional filtering predicate.
      • alwaysTrue

        public static <T> IgnitePredicate<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> IgnitePredicate<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

        @Deprecated
        public static boolean isAlwaysTrue​(IgnitePredicate p)
        Deprecated.
        Tests whether or not given predicate is the one returned from alwaysTrue() method.
        Parameters:
        p - Predicate to check.
        Returns:
        true if given predicate is ALWAYS_TRUE predicate.
      • isAlwaysTrue

        public static boolean isAlwaysTrue​(@Nullable
                                           @Nullable IgnitePredicate[] p)
        Tests whether or not given set of predicates consists only of one predicate returned from alwaysTrue() method.
        Parameters:
        p - Predicate to check.
        Returns:
        true if given contains only ALWAYS_TRUE predicate.
      • isAlwaysFalse

        @Deprecated
        public static boolean isAlwaysFalse​(IgnitePredicate p)
        Deprecated.
        Tests whether or not given predicate is the one returned from alwaysFalse() method.
        Parameters:
        p - Predicate to check.
        Returns:
        true if given predicate is ALWAYS_FALSE predicate.
      • isAlwaysFalse

        @Deprecated
        public static boolean isAlwaysFalse​(@Nullable
                                            @Nullable IgnitePredicate[] p)
        Deprecated.
        Tests whether or not given set of predicates consists only of one predicate returned from alwaysFalse() method.
        Parameters:
        p - Predicate to check.
        Returns:
        true if given contains only ALWAYS_FALSE predicate.
      • notNull

        public static <T> IgnitePredicate<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

        @SafeVarargs
        public static <T> IgnitePredicate<T> not​(@Nullable
                                                 @Nullable IgnitePredicate<? 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

        @Deprecated
        public static <T> IgnitePredicate<T> equalTo​(@Nullable
                                                     T target)
        Deprecated.
        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> IgnitePredicate<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.
      • first

        public static <T> T first​(@Nullable
                                  @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.
      • first

        public static <T> T first​(List<? extends T> list)
        Gets first element from given list or returns null if list is empty.
        Parameters:
        list - List.
        Returns:
        List' first element or null in case if list is empty.
      • last

        @Deprecated
        @Nullable
        public static <T> T last​(@Nullable
                                 @Nullable Iterable<? extends T> c)
        Deprecated.
        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

        @Deprecated
        @Nullable
        public static <K> K firstKey​(Map<K,​?> m)
        Deprecated.
        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<K,​V> 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> IgnitePredicate<T> and​(@Nullable
                                                 @Nullable IgnitePredicate<? 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.
      • identity

        public static <T> IgniteClosure<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.
      • string

        @Deprecated
        public static <T> IgniteClosure<T,​String> string()
        Deprecated.
        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.
      • notIn

        public static <T> IgnitePredicate<T> notIn​(@Nullable
                                                   @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.
      • addAll

        @Deprecated
        public static <T,​C extends Collection<T>> C addAll​(C c,
                                                                 Iterable<? extends T> it)
        Deprecated.
        Parameters:
        c - Target collection.
        it - Iterable to fetch.
        Returns:
        Modified target collection.
      • addAll

        @Deprecated
        public static <T,​C extends Collection<T>> C addAll​(C c,
                                                                 Iterator<? extends T> it)
        Deprecated.
        Parameters:
        c - Target collection.
        it - Iterator to fetch.
        Returns:
        Modified target collection.
      • addIfAbsent

        public static <K,​V> V addIfAbsent​(ConcurrentMap<K,​V> map,
                                                K key,
                                                @Nullable
                                                @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<? super K,​V> map,
                                                @Nullable
                                                K key,
                                                @Nullable
                                                @Nullable Callable<? extends V> c)
        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).
        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.
        Throws:
        GridClosureException - Thrown in case when callable throws exception.
        See Also:
        newSet(), newAtomicInt()
      • 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.
      • forEach

        @Deprecated
        public static <X> void forEach​(Iterable<? extends X> c,
                                       IgniteInClosure<? super X> f,
                                       @Nullable
                                       @Nullable IgnitePredicate<? super X>... p)
        Deprecated.
        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

        @Deprecated
        public static <X> void forEach​(X[] c,
                                       IgniteInClosure<? super X> f,
                                       @Nullable
                                       @Nullable IgnitePredicate<? super X>... p)
        Deprecated.
        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.
      • copy

        @Deprecated
        public static <T> Collection<T> copy​(Collection<T> to,
                                             T... from)
        Deprecated.
        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

        @Deprecated
        public static <T> Collection<T> copy​(Collection<T> to,
                                             Iterable<? extends T> from,
                                             @Nullable
                                             @Nullable IgnitePredicate<? super T>... p)
        Deprecated.
        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<? extends X> c,
                                                          IgniteClosure<? 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.
      • transform

        @Deprecated
        public static <X,​Y> Collection<Y> transform​(X[] c,
                                                          IgniteClosure<? super X,​Y> f)
        Deprecated.
        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
                                        @Nullable IgnitePredicate<? 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.
      • isAny

        @Deprecated
        public static <T> boolean isAny​(@Nullable
                                        T t,
                                        @Nullable
                                        @Nullable IgnitePredicate<? super T>... p)
        Deprecated.
        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.
      • noop

        @Deprecated
        public static GridAbsClosure noop()
        Deprecated.
        Creates an absolute (no-arg) closure that does nothing.
        Returns:
        Absolute (no-arg) closure that does nothing.
      • find

        @SafeVarargs
        @Nullable
        public static <V> V find​(Iterable<? extends V> c,
                                 @Nullable
                                 V dfltVal,
                                 @Nullable
                                 @Nullable IgnitePredicate<? 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.
      • containsAny

        @Deprecated
        public static <T> boolean containsAny​(@Nullable
                                              @Nullable Collection<? extends T> c1,
                                              @Nullable
                                              @Nullable Iterable<? extends T> c2)
        Deprecated.
        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
                                              @Nullable Collection<? extends T> c1,
                                              @Nullable
                                              @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

        @Deprecated
        public static <T> boolean containsAll​(@Nullable
                                              @Nullable Collection<? extends T> c1,
                                              @Nullable
                                              @Nullable Iterable<? extends T> c2)
        Deprecated.
        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.
      • pair

        @Deprecated
        public static <T> IgnitePair<T> pair​(@Nullable
                                             T t1,
                                             @Nullable
                                             T t2)
        Deprecated.
        Use T2 instead.
        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.
      • partition

        @Deprecated
        public static <V> IgniteBiTuple<Collection<V>,​Collection<V>> partition​(Iterable<? extends V> c,
                                                                                     IgnitePredicate<? super V> p)
        Deprecated.
        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.
      • exist

        public static <V> boolean exist​(Iterable<? extends V> c,
                                        @Nullable
                                        @Nullable IgnitePredicate<? 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.
      • forAll

        @Deprecated
        public static <V> boolean forAll​(Iterable<? extends V> c,
                                         @Nullable
                                         @Nullable IgnitePredicate<? super V>... p)
        Deprecated.
        Applies all given predicates to all elements in given input collection and returns true if all of them evaluate to true for all elements. Returns false otherwise.
        Type Parameters:
        V - Type of the collection element.
        Parameters:
        c - Input collection.
        p - Optional set of checking predicates. If none provided - true is returned.
        Returns:
        Returns true if all given predicates evaluate to true for all elements. Returns false otherwise.
      • forAll

        @Deprecated
        public static <K1,​K extends K1,​V1,​V extends V1> boolean forAll​(Map<K,​V> m,
                                                                                         @Nullable
                                                                                         @Nullable IgnitePredicate<? super Map.Entry<K,​V>>... p)
        Deprecated.
        Applies given predicates to all entries in given input map and returns true if all of them evaluates to true for all entries. Returns false otherwise.
        Type Parameters:
        K - Type of the map keys.
        V - Type of the map values.
        Parameters:
        m - Input map.
        p - Optional set of checking predicate.
        Returns:
        Returns true if all given predicate evaluates to true for all entries. Returns false otherwise.
      • forAny

        @Deprecated
        public static <V> boolean forAny​(Iterable<? extends V> c,
                                         @Nullable
                                         @Nullable IgnitePredicate<? super V>... p)
        Deprecated.
        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. Returns false otherwise. Processing will short-circuit after first element evaluates to true for all predicates.
        Type Parameters:
        V - Type of the collection element.
        Parameters:
        c - Input collection.
        p - Optional set of checking predicates. If none provided - true is returned.
        Returns:
        Returns true if all given predicates evaluate to true for at least one element. Returns false otherwise.
      • fold

        @Deprecated
        @Nullable
        public static <D,​B> B fold​(Iterable<? extends D> c,
                                         @Nullable
                                         B b,
                                         @Nullable
                                         @Nullable IgniteBiClosure<? super D,​? super B,​B>... fs)
        Deprecated.
        Folds-right given collection using provided closure. If input collection contains a1, a2, ..., an result value will be ...f(f(f(b,a1),a2),a3)... where f(x) is the result of applying each closure from fs set to the element x of the input collection c.

        For example:

         ...
        
         Collection<Integer> nums = new ArrayList<Integer>(size);
        
         // Search max value.
         Integer max = F.fold(nums, F.first(nums), new C2<Integer, Integer, Integer>() {
             public Integer apply(Integer n, Integer max) { return Math.max(n, max); }
         });
        
         ...
         
        Type Parameters:
        D - Type of the input collection elements and type of the free variable for the closure.
        B - Type of the folding value and return type of the closure.
        Parameters:
        c - Input collection.
        b - Optional first folding pair element.
        fs - Optional set of folding closures.
        Returns:
        Value representing folded collection.
      • t

        public static <V> GridTuple<V> t​(@Nullable
                                         V v)
        Factory method returning new tuple with given parameter.
        Type Parameters:
        V - Type of the tuple.
        Parameters:
        v - Parameter for tuple.
        Returns:
        Newly created tuple.
      • t1

        @Deprecated
        public static <V> GridTuple<V> t1()
        Deprecated.
        Factory method returning empty tuple.
        Type Parameters:
        V - Type of the tuple.
        Returns:
        Newly created empty tuple.
      • t

        public static <V1,​V2> IgniteBiTuple<V1,​V2> t​(@Nullable
                                                                 V1 v1,
                                                                 @Nullable
                                                                 V2 v2)
        Factory method returning new tuple with given parameters.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        Parameters:
        v1 - 1st parameter for tuple.
        v2 - 2nd parameter for tuple.
        Returns:
        Newly created tuple.
      • t2

        @Deprecated
        public static <V1,​V2> IgniteBiTuple<V1,​V2> t2()
        Deprecated.
        Factory method returning new empty tuple.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        Returns:
        Newly created empty tuple.
      • t

        public static <V1,​V2,​V3> GridTuple3<V1,​V2,​V3> t​(@Nullable
                                                                                V1 v1,
                                                                                @Nullable
                                                                                V2 v2,
                                                                                @Nullable
                                                                                V3 v3)
        Factory method returning new tuple with given parameters.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        Parameters:
        v1 - 1st parameter for tuple.
        v2 - 2nd parameter for tuple.
        v3 - 3rd parameter for tuple.
        Returns:
        Newly created tuple.
      • t

        @Deprecated
        public static <V1,​V2,​V3,​V4> GridTuple4<V1,​V2,​V3,​V4> t​(@Nullable
                                                                                                  V1 v1,
                                                                                                  @Nullable
                                                                                                  V2 v2,
                                                                                                  @Nullable
                                                                                                  V3 v3,
                                                                                                  @Nullable
                                                                                                  V4 v4)
        Deprecated.
        Factory method returning new tuple with given parameters.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        Parameters:
        v1 - 1st parameter for tuple.
        v2 - 2nd parameter for tuple.
        v3 - 3rd parameter for tuple.
        v4 - 4th parameter for tuple.
        Returns:
        Newly created tuple.
      • t

        @Deprecated
        public static <V1,​V2,​V3,​V4,​V5> GridTuple5<V1,​V2,​V3,​V4,​V5> t​(@Nullable
                                                                                                                    V1 v1,
                                                                                                                    @Nullable
                                                                                                                    V2 v2,
                                                                                                                    @Nullable
                                                                                                                    V3 v3,
                                                                                                                    @Nullable
                                                                                                                    V4 v4,
                                                                                                                    @Nullable
                                                                                                                    V5 v5)
        Deprecated.
        Factory method returning new tuple with given parameters.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        V5 - Type of the 5th tuple parameter.
        Parameters:
        v1 - 1st parameter for tuple.
        v2 - 2nd parameter for tuple.
        v3 - 3rd parameter for tuple.
        v4 - 4th parameter for tuple.
        v5 - 5th parameter for tuple.
        Returns:
        Newly created tuple.
      • t

        @Deprecated
        public static <V1,​V2,​V3,​V4,​V5,​V6> GridTuple6<V1,​V2,​V3,​V4,​V5,​V6> t​(@Nullable
                                                                                                                                      V1 v1,
                                                                                                                                      @Nullable
                                                                                                                                      V2 v2,
                                                                                                                                      @Nullable
                                                                                                                                      V3 v3,
                                                                                                                                      @Nullable
                                                                                                                                      V4 v4,
                                                                                                                                      @Nullable
                                                                                                                                      V5 v5,
                                                                                                                                      @Nullable
                                                                                                                                      V6 v6)
        Deprecated.
        Factory method returning new tuple with given parameters.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        V5 - Type of the 5th tuple parameter.
        V6 - Type of the 6th tuple parameter.
        Parameters:
        v1 - 1st parameter for tuple.
        v2 - 2nd parameter for tuple.
        v3 - 3rd parameter for tuple.
        v4 - 4th parameter for tuple.
        v5 - 5th parameter for tuple.
        v6 - 5th parameter for tuple.
        Returns:
        Newly created tuple.
      • t3

        @Deprecated
        public static <V1,​V2,​V3> GridTuple3<V1,​V2,​V3> t3()
        Deprecated.
        Factory method returning new empty tuple.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        Returns:
        Newly created empty tuple.
      • t4

        @Deprecated
        public static <V1,​V2,​V3,​V4> GridTuple4<V1,​V2,​V3,​V4> t4()
        Deprecated.
        Factory method returning new empty tuple.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        Returns:
        Newly created empty tuple.
      • t5

        @Deprecated
        public static <V1,​V2,​V3,​V4,​V5> GridTuple5<V1,​V2,​V3,​V4,​V5> t5()
        Deprecated.
        Factory method returning new empty tuple.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        V5 - Type of the 5th tuple parameter.
        Returns:
        Newly created empty tuple.
      • t6

        @Deprecated
        public static <V1,​V2,​V3,​V4,​V5,​V6> GridTuple6<V1,​V2,​V3,​V4,​V5,​V6> t6()
        Deprecated.
        Factory method returning new empty tuple.
        Type Parameters:
        V1 - Type of the 1st tuple parameter.
        V2 - Type of the 2nd tuple parameter.
        V3 - Type of the 3rd tuple parameter.
        V4 - Type of the 4th tuple parameter.
        V5 - Type of the 5th tuple parameter.
        V6 - Type of the 6th tuple parameter.
        Returns:
        Newly created empty tuple.
      • zip

        @Deprecated
        public static <K,​V> Map<K,​V> zip​(Collection<? extends K> keys,
                                                     V dfltVal)
        Deprecated.
        Converts collection to map using collection values as keys and passed in default value as values.
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        keys - Map keys.
        dfltVal - Default value.
        Returns:
        Resulting map.
      • asMap

        public static <K,​V> Map<K,​V> asMap​(K k,
                                                       V v)
        Creates map with given values.
        Type Parameters:
        K - Key's type.
        V - Value's type.
        Parameters:
        k - Key.
        v - Value.
        Returns:
        Created map.
      • asMap

        public static <K,​V> Map<K,​V> asMap​(K k1,
                                                       V v1,
                                                       K k2,
                                                       V v2)
        Creates map with given values.
        Type Parameters:
        K - Key's type.
        V - Value's type.
        Parameters:
        k1 - Key 1.
        v1 - Value 1.
        k2 - Key 2.
        v2 - Value 2.
        Returns:
        Created map.
      • asMap

        @Deprecated
        public static <K,​V> Map<K,​V> asMap​(K k1,
                                                       V v1,
                                                       K k2,
                                                       V v2,
                                                       K k3,
                                                       V v3)
        Deprecated.
        Creates map with given values.
        Type Parameters:
        K - Key's type.
        V - Value's type.
        Parameters:
        k1 - Key 1.
        v1 - Value 1.
        k2 - Key 2.
        v2 - Value 2.
        k3 - Key 3.
        v3 - Value 3.
        Returns:
        Created map.
      • asMap

        @Deprecated
        public static <K,​V> Map<K,​V> asMap​(K k1,
                                                       V v1,
                                                       K k2,
                                                       V v2,
                                                       K k3,
                                                       V v3,
                                                       K k4,
                                                       V v4)
        Deprecated.
        Creates map with given values.
        Type Parameters:
        K - Key's type.
        V - Value's type.
        Parameters:
        k1 - Key 1.
        v1 - Value 1.
        k2 - Key 2.
        v2 - Value 2.
        k3 - Key 3.
        v3 - Value 3.
        k4 - Key 4.
        v4 - Value 4.
        Returns:
        Created map.
      • asMap

        @Deprecated
        public 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)
        Deprecated.
        Creates map with given values.
        Type Parameters:
        K - Key's type.
        V - Value's type.
        Parameters:
        k1 - Key 1.
        v1 - Value 1.
        k2 - Key 2.
        v2 - Value 2.
        k3 - Key 3.
        v3 - Value 3.
        k4 - Key 4.
        v4 - Value 4.
        k5 - Key 5.
        v5 - Value 5.
        Returns:
        Created map.
      • asArray

        public static <T> T[] asArray​(T... t)
        Convenience method to convert multiple elements into array.
        Type Parameters:
        T - Element type.
        Parameters:
        t - Elements to convert into array.
        Returns:
        Array of elements.
      • asList

        public static <T> List<T> asList​(@Nullable
                                         T t)
        Creates read-only list with given values.
        Type Parameters:
        T - Element's type.
        Parameters:
        t - Element (if null, then empty list is returned).
        Returns:
        Created list.
      • asSet

        @Deprecated
        public static <T> Set<T> asSet​(@Nullable
                                       T t)
        Deprecated.
        Creates read-only set with given value.
        Type Parameters:
        T - Element's type.
        Parameters:
        t - Element (if null, then empty set is returned).
        Returns:
        Created set.
      • asSet

        @Deprecated
        public static <T> Set<T> asSet​(@Nullable
                                       @Nullable T... t)
        Deprecated.
        Creates read-only set with given values.
        Type Parameters:
        T - Element's type.
        Parameters:
        t - Element (if null, then empty set is returned).
        Returns:
        Created set.
      • contains

        public static <T> boolean contains​(@Nullable
                                           @Nullable Collection<T> c,
                                           @Nullable
                                           T t)
        Checks if value is contained in the collection passed in. If the collection is null, then false is returned.
        Type Parameters:
        T - Value type.
        Parameters:
        c - Collection to check.
        t - Value to check for containment.
        Returns:
        True if collection is not null and contains given value, false otherwise.
      • contains

        public static <T> IgnitePredicate<T> contains​(@Nullable
                                                      @Nullable Collection<T> c)
        Provides predicate which returns true if it receives an element that is contained in the passed in collection.
        Type Parameters:
        T - Element type.
        Parameters:
        c - Collection used for predicate filter.
        Returns:
        Predicate which returns true if it receives an element that is contained in the passed in collection.
      • notContains

        public static <T> IgnitePredicate<T> notContains​(@Nullable
                                                         @Nullable Collection<T> c)
        Provides predicate which returns true if it receives an element that is not contained in the passed in collection.
        Type Parameters:
        T - Element type.
        Parameters:
        c - Collection used for predicate filter.
        Returns:
        Predicate which returns true if it receives an element that is not contained in the passed in collection.
      • contains

        public static boolean contains​(int[] arr,
                                       int val)
        Parameters:
        arr - Array.
        val - Value to find.
        Returns:
        True if array contains given value.
      • mapContainsKey

        public static <T> boolean mapContainsKey​(@Nullable
                                                 @Nullable Map<T,​?> m,
                                                 T k)
        Checks if key is contained in the map passed in. If the map is null, then false is returned.
        Type Parameters:
        T - Key type.
        Parameters:
        m - Map to check.
        k - Key to check for containment.
        Returns:
        true if map is not null and contains given key, false otherwise.
      • constainsStringIgnoreCase

        public static boolean constainsStringIgnoreCase​(@Nullable
                                                        @Nullable Collection<String> col,
                                                        String val)
        Check's that val contains ignore case in collection col.
        Parameters:
        col - Collection of values.
        val - Checked value.
        Returns:
        true, if at least one element of col and @val are equal ignore case, and false otherwise.
      • constainsStringIgnoreCase

        public static boolean constainsStringIgnoreCase​(@Nullable
                                                        @Nullable String[] arr,
                                                        String val)
        Check's that val contains ignore case in array arr.
        Parameters:
        arr - Array of values.
        val - Checked value.
        Returns:
        true, if at least one element of arr and val are equal ignore case, and false otherwise.
      • contains

        @Deprecated
        public static boolean contains​(Integer[] arr,
                                       int val)
        Deprecated.
        Parameters:
        arr - Array.
        val - Value to find.
        Returns:
        True if array contains given value.
      • contains

        @Deprecated
        public static boolean contains​(long[] arr,
                                       long val)
        Deprecated.
        Parameters:
        arr - Array.
        val - Value to find.
        Returns:
        True if array contains given value.
      • eq

        public static boolean eq​(@Nullable
                                 @Nullable Object o1,
                                 @Nullable
                                 @Nullable Object o2)
        Tests whether specified arguments are equal, or both null.
        Parameters:
        o1 - Object to compare.
        o2 - Object to compare.
        Returns:
        Returns true if the specified arguments are equal, or both null.
      • eqOrdered

        @Deprecated
        public static boolean eqOrdered​(@Nullable
                                        @Nullable Collection<?> c1,
                                        @Nullable
                                        @Nullable Collection<?> c2)
        Deprecated.
        Checks if both collections have equal elements in the same order.
        Parameters:
        c1 - First collection.
        c2 - Second collection.
        Returns:
        True if both collections have equal elements in the same order.
      • eqNotOrdered

        public static boolean eqNotOrdered​(@Nullable
                                           @Nullable Collection<?> c1,
                                           @Nullable
                                           @Nullable Collection<?> c2)
        Checks if both collections have equal elements in any order.

        Implementation of this method takes optimization steps based on the actual type of the collections. Dups are allowed in the collection. Note that if collections allow fixed-time random access (implementing RandomAccess marker interface - having them pre-sorted dramatically improves the performance.

        Parameters:
        c1 - First collection.
        c2 - Second collection.
        Returns:
        True if both collections have equal elements in any order.
      • eqNotOrdered

        public static <K,​V> boolean eqNotOrdered​(@Nullable
                                                       @Nullable Map<K,​V> m1,
                                                       @Nullable
                                                       @Nullable Map<K,​V> m2)
        Compares two maps. Unlike java.util.AbstractMap#equals(...) method this implementation checks not only entry sets, but also the keys. Some optimization checks are also used.
        Parameters:
        m1 - First map to check.
        m2 - Second map to check
        Returns:
        True is maps are equal, False otherwise.
      • eqNodes

        public static boolean eqNodes​(Object n1,
                                      Object n2)
        Compares two ClusterNode instances for equality.

        Since introduction of ClusterNode in Apache Ignite 3.0 the semantic of equality between grid nodes has changed. Since rich node wraps thin node instance and in the same time implements ClusterNode interface, the proper semantic of comparing two grid node is to ignore their runtime types and compare only by their IDs. This method implements this logic.

        End users rarely, if ever, need to directly compare two grid nodes for equality. This method is intended primarily for discovery SPI developers that provide implementations of ClusterNode interface.

        Parameters:
        n1 - Grid node 1.
        n2 - Grid node 2
        Returns:
        true if two grid node have the same IDs (ignoring their runtime types), false otherwise.
      • cacheEntry2Get

        public static <K,​V> IgniteClosure<javax.cache.Cache.Entry<K,​V>,​V> cacheEntry2Get()
        Gets closure that returns value for an entry. The closure internally delegates to Cache.get(Object) method.
        Type Parameters:
        K - Key type.
        V - Value type.
        Returns:
        Closure that returns value for an entry.
      • cacheHasPeekValue

        public static <K,​V> IgnitePredicate<javax.cache.Cache.Entry<K,​V>> cacheHasPeekValue()
        Gets predicate which returns true if entry has peek value.
        Type Parameters:
        K - Cache key type.
        V - Cache value type.
        Returns:
        Predicate which returns true if entry has peek value.
      • awaitAll

        @Deprecated
        @Nullable
        public static <T,​R> R awaitAll​(long timeout,
                                             @Nullable
                                             @Nullable IgniteReducer<T,​R> rdc,
                                             @Nullable
                                             @Nullable Collection<IgniteInternalFuture<T>> futs)
                                      throws IgniteCheckedException
        Deprecated.
        Awaits for all futures to complete and optionally reduces all results into one.
        Type Parameters:
        T - Return type of the futures.
        R - Return type of the reducer.
        Parameters:
        timeout - Timeout for waiting (0 for forever).
        rdc - Optional reducer. If not null, then results will be reduced into one.
        futs - List of futures to wait for.
        Returns:
        Reduced result if reducer is provided, null otherwise.
        Throws:
        IgniteCheckedException - If any of the futures failed.
      • isSorted

        public static boolean isSorted​(long[] arr)
        Parameters:
        arr - Array to check.
        Returns:
        True if array sorted, false otherwise.
      • isSorted

        public static boolean isSorted​(int[] arr)
        Parameters:
        arr - Array to check.
        Returns:
        True if array sorted, false otherwise.
      • nonThrowableSupplier

        public static BooleanSupplier nonThrowableSupplier​(BooleanSupplier s,
                                                           IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce 0 on any exception in s.
        Parameters:
        s - Root supplier.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static DoubleSupplier nonThrowableSupplier​(DoubleSupplier s,
                                                          IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce .0d on any exception in s.
        Parameters:
        s - Root supplier.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static IntSupplier nonThrowableSupplier​(IntSupplier s,
                                                       IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce 0 on any exception in s.
        Parameters:
        s - Root supplier.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static LongSupplier nonThrowableSupplier​(LongSupplier s,
                                                        IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce 0 on any exception in s.
        Parameters:
        s - Root supplier.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static <T> Supplier<T> nonThrowableSupplier​(Supplier<T> s,
                                                           IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce null on any exception in s.
        Parameters:
        s - Root supplier.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static BooleanSupplier nonThrowableSupplier​(BooleanSupplier s,
                                                           boolean dfltVal,
                                                           IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce dfltVal on any exception in s.
        Parameters:
        s - Root supplier.
        dfltVal - Value returned on exception in s.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static DoubleSupplier nonThrowableSupplier​(DoubleSupplier s,
                                                          double dfltVal,
                                                          IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce dfltVal on any exception in s.
        Parameters:
        s - Root supplier.
        dfltVal - Value returned on exception in s.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static IntSupplier nonThrowableSupplier​(IntSupplier s,
                                                       int dfltVal,
                                                       IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce dfltVal on any exception in s.
        Parameters:
        s - Root supplier.
        dfltVal - Value returned on exception in s.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static LongSupplier nonThrowableSupplier​(LongSupplier s,
                                                        long dfltVal,
                                                        IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce dfltVal on any exception in s.
        Parameters:
        s - Root supplier.
        dfltVal - Value returned on exception in s.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • nonThrowableSupplier

        public static <T> Supplier<T> nonThrowableSupplier​(Supplier<T> s,
                                                           T dfltVal,
                                                           IgniteLogger log)
        Return supplier that suppress any exception throwed by s. Returned supplier will produce dfltVal on any exception in s.
        Parameters:
        s - Root supplier.
        dfltVal - Value returned on exception in s.
        log - Logger.
        Returns:
        Supplier that suppress any exception throwed by s.
      • isArray

        public static boolean isArray​(Object val)
        Parameters:
        val - Value to check.
        Returns:
        True if not null and array.
      • arrayEq

        public static boolean arrayEq​(Object a1,
                                      Object a2)
        Check for arrays equality.
        Parameters:
        a1 - Value 1.
        a2 - Value 2.
        Returns:
        True if arrays equal.
      • compareArrays

        public static int compareArrays​(Object a1,
                                        Object a2)
        Compare arrays.
        Parameters:
        a1 - Value 1.
        a2 - Value 2.
        Returns:
        a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
      • compareArrays

        public static int compareArrays​(Object[] a1,
                                        Object[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(byte[] a1,
                                        byte[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(boolean[] a1,
                                        boolean[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(short[] a1,
                                        short[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(char[] a1,
                                        char[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(int[] a1,
                                        int[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(long[] a1,
                                        long[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(float[] a1,
                                        float[] a2)
        Compare arrays.
      • compareArrays

        public static int compareArrays​(double[] a1,
                                        double[] a2)
        Compare arrays.