Package io.debezium.util
Class Sequences
- java.lang.Object
-
- io.debezium.util.Sequences
-
@Immutable public class Sequences extends Object
Utility methods for obtaining streams of integers.- Author:
- Randall Hauch
-
-
Constructor Summary
Constructors Constructor Description Sequences()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Iterable<Integer>
infiniteIntegers()
Create an iterator over an infinite number of monotonically increasing numbers starting at 0, useful when performing an operation an unknown number of times.static Iterable<Integer>
infiniteIntegers(int startingAt)
Create an iterator over an infinite number monotonically increasing numbers starting at the given number, useful when performing an operation an unknown number of times.static <T> Supplier<T>
randomlySelect(T... values)
Obtain a supplier function that randomly selects from the given values.static <T> Supplier<T>
randomlySelect(T first, T... additional)
Obtain a supplier function that randomly selects from the given values.static IntStream
times(int number)
Create a stream of number monotonically increasing numbers starting at 0, useful when performing an operation number times.
-
-
-
Method Detail
-
times
public static IntStream times(int number)
Create a stream of number monotonically increasing numbers starting at 0, useful when performing an operation number times.- Parameters:
number
- the number of values to include in the stream; must be positive- Returns:
- the sequence; never null
-
infiniteIntegers
public static Iterable<Integer> infiniteIntegers()
Create an iterator over an infinite number of monotonically increasing numbers starting at 0, useful when performing an operation an unknown number of times.- Returns:
- the sequence; never null
-
infiniteIntegers
public static Iterable<Integer> infiniteIntegers(int startingAt)
Create an iterator over an infinite number monotonically increasing numbers starting at the given number, useful when performing an operation an unknown number of times.- Parameters:
startingAt
- the first number to include in the resulting stream- Returns:
- the sequence; never null
-
randomlySelect
@SafeVarargs public static <T> Supplier<T> randomlySelect(T first, T... additional)
Obtain a supplier function that randomly selects from the given values. If the supplied values contain nulls, then the resulting supplier function may return null values.- Parameters:
first
- the first value that may be randomly pickedadditional
- the additional values to randomly pick from; may be null or empty- Returns:
- the supplier function; never null
-
randomlySelect
@SafeVarargs public static <T> Supplier<T> randomlySelect(T... values)
Obtain a supplier function that randomly selects from the given values. If the supplied values contain nulls, then the resulting supplier function may return null values.- Parameters:
values
- the values to randomly pick from; may not be null, should not be empty- Returns:
- the supplier function; never null
-
-