public class PluginDefaultGroovyMethods
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
asBoolean(java.util.Optional<?> optional)
Coerce an Optional instance to a boolean value.
|
static <S,T> java.util.concurrent.Future<T> |
collect(java.util.concurrent.Future<S> self,
Closure<T> transform)
Returns a Future asynchronously returning a transformed result.
|
static <S,T> java.util.Optional<T> |
collect(java.util.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 java.util.stream.Stream<java.lang.Boolean> |
stream(boolean[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Byte> |
stream(byte[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Character> |
stream(char[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Double> |
stream(double[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Float> |
stream(float[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Integer> |
stream(int[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Long> |
stream(long[] self)
Returns a sequential
Stream with the specified array as its
source. |
static java.util.stream.Stream<java.lang.Short> |
stream(short[] self)
Returns a sequential
Stream with the specified array as its
source. |
static <T> java.util.stream.Stream<T> |
stream(T[] self)
Returns a sequential
Stream with the specified array as its
source. |
static <T> java.util.List<T> |
toList(java.util.stream.BaseStream<T,? extends java.util.stream.BaseStream> stream)
Accumulates the elements of stream into a new List.
|
static <T> java.util.List<T> |
toList(java.util.stream.Stream<T> stream)
Accumulates the elements of stream into a new List.
|
static <T> java.util.Set<T> |
toSet(java.util.stream.BaseStream<T,? extends java.util.stream.BaseStream> stream)
Accumulates the elements of stream into a new Set.
|
static <T> java.util.Set<T> |
toSet(java.util.stream.Stream<T> stream)
Accumulates the elements of stream into a new Set.
|
public static boolean asBoolean(java.util.Optional<?> optional)
optional - the Optionaltrue if a value is present, otherwise falsepublic static <S,T> java.util.Optional<T> collect(java.util.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> java.util.concurrent.Future<T> collect(java.util.concurrent.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> java.util.List<T> toList(java.util.stream.Stream<T> stream)
T - the type of elementstream - the Streamjava.util.List instancepublic static <T> java.util.Set<T> toSet(java.util.stream.Stream<T> stream)
T - the type of elementstream - the Streamjava.util.Set instancepublic static <T> java.util.List<T> toList(java.util.stream.BaseStream<T,? extends java.util.stream.BaseStream> stream)
T - the type of elementstream - the java.util.stream.BaseStreamjava.util.List instancepublic static <T> java.util.Set<T> toSet(java.util.stream.BaseStream<T,? extends java.util.stream.BaseStream> stream)
T - the type of elementstream - the java.util.stream.BaseStreamjava.util.Set instancepublic static <T> java.util.stream.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.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 java.util.stream.Stream<java.lang.Boolean> stream(boolean[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the arraypublic static java.util.stream.Stream<java.lang.Float> stream(float[] self)
Stream with the specified array as its
source.self - The array, assumed to be unmodified during useStream for the array