public class PluginDefaultGroovyMethods extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
asBoolean(Optional<?> optional)
Coerce an Optional instance to a boolean value.
|
static <S,T> Future<T> |
collect(Future<S> self,
Closure<T> transform)
Returns a Future asynchronously returning a transformed result.
|
static <S,T> Optional<T> |
collect(Optional<S> self,
Closure<T> transform)
If the optional contains a value, returns an optional containing the transformed value obtained using the
transform closure
or otherwise an empty optional. |
static Stream<Boolean> |
stream(boolean[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Byte> |
stream(byte[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Character> |
stream(char[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Double> |
stream(double[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Float> |
stream(float[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Integer> |
stream(int[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Long> |
stream(long[] self)
Returns a sequential
Stream with the specified array as its
source. |
static Stream<Short> |
stream(short[] self)
Returns a sequential
Stream with the specified array as its
source. |
static <T> Stream<T> |
stream(T[] self)
Returns a sequential
Stream with the specified array as its
source. |
static <T> List<T> |
toList(BaseStream<T,? extends BaseStream> stream)
Accumulates the elements of stream into a new List.
|
static <T> List<T> |
toList(Stream<T> stream)
Accumulates the elements of stream into a new List.
|
static <T> Set<T> |
toSet(BaseStream<T,? extends BaseStream> stream)
Accumulates the elements of stream into a new Set.
|
static <T> Set<T> |
toSet(Stream<T> stream)
Accumulates the elements of stream into a new Set.
|
public static boolean asBoolean(Optional<?> optional)
optional - the Optionaltrue if a value is present, otherwise falsepublic static <S,T> Optional<T> collect(Optional<S> self, Closure<T> transform)
transform closure
or otherwise an empty optional.
assert Optional.of("foobar").collect{ it.size() }.get() == 6
assert !Optional.empty().collect{ it.size() }.isPresent()
self - an Optionaltransform - the closure used to transform the optional value if presentpublic static <S,T> Future<T> collect(Future<S> self, Closure<T> transform)
import java.util.concurrent.* def executor = Executors.newSingleThreadExecutor() Futurefoobar = executor.submit{ "foobar" } Future foobarSize = foobar.collect{ it.size() } assert foobarSize.get() == 6 executor.shutdown()
self - a Futuretransform - the closure used to transform the Future valuepublic static <T> List<T> toList(Stream<T> stream)
T - the type of elementstream - the Streamjava.util.List instancepublic static <T> Set<T> toSet(Stream<T> stream)
T - the type of elementstream - the Streamjava.util.Set instancepublic static <T> List<T> toList(BaseStream<T,? extends BaseStream> stream)
T - the type of elementstream - the java.util.stream.BaseStreamjava.util.List instancepublic static <T> Set<T> toSet(BaseStream<T,? extends BaseStream> stream)
T - the type of elementstream - the java.util.stream.BaseStreamjava.util.Set instancepublic static <T> Stream<T> stream(T[] self)
Stream with the specified array as its
source.T - The type of the array elementsself - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Integer> stream(int[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Long> stream(long[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Double> stream(double[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Character> stream(char[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Byte> stream(byte[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Short> stream(short[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static Stream<Boolean> stream(boolean[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the array