Top Description Inners Constructors Methods
org.codehaus.groovy.vmplugin.v8

public Class PluginDefaultGroovyMethods

extends DefaultGroovyMethodsSupport
Class Inheritance
Imports
groovy.lang.Closure, .EmptyRange, .GString, .IntRange, groovy.transform.stc.ClosureParams, .FirstParam, org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport, .InvokerHelper, .NullObject, .RangeInfo, java.lang.reflect.Array, .Method, java.util.Arrays, .Enumeration, .Iterator, .List, .Objects, .Optional, .OptionalDouble, .OptionalInt, .OptionalLong, .Set, .Spliterator, .Spliterators, java.util.concurrent.ExecutionException, .Future, .TimeUnit, .TimeoutException, java.util.function.Consumer, .DoubleFunction, .DoublePredicate, .IntFunction, .IntPredicate, .LongFunction, .LongPredicate, .Supplier, .ToDoubleFunction, .ToIntFunction, .ToLongFunction, java.util.stream.BaseStream, .Collectors, .DoubleStream, .IntStream, .LongStream, .Stream, .StreamSupport

Defines new Groovy methods which appear on standard Java 8 classes within the Groovy environment.
Since
2.5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if a value is present, otherwise false
asBoolean
(final Optional<?>
the Optional
optional
)

Coerce an Optional instance to a boolean value.

public static <S, T> Optional<T>

Returns:

an Optional containing the transformed value or empty if the optional is empty or the transform returns null
collect
(final Optional<S>
an Optional
self
,
final Closure<T>
the closure used to transform the optional value if present
transform
)

If the optional contains a value, returns an optional containing the transformed value obtained using the transform closure or otherwise an empty optional.

public static <S, T> Future<T>

Returns:

a Future allowing the transformed value to be obtained asynchronously
collect
(final Future<S>
a Future
self
,
final Closure<T>
the closure used to transform the Future value
transform
)

Returns a Future asynchronously returning a transformed result.

public static DoubleStream

Returns:

a Stream for the array
doubleStream
(final double[]
The array, assumed to be unmodified during use
self
)

Returns a sequential DoubleStream with the specified array as its source.

public static <T> Optional<T>
filter(final Optional<?> self, final Class<T> type)

Tests given value against specified type and changes generics of result.

public static OptionalInt
filter(final OptionalInt self, final IntPredicate test)

If a value is present in the OptionalInt, tests the value using the given predicate and returns the optional if the test returns true or else empty.

public static OptionalLong
filter(final OptionalLong self, final LongPredicate test)

If a value is present in the OptionalLong, tests the value using the given predicate and returns the optional if the test returns true or else empty.

public static OptionalDouble
filter(final OptionalDouble self, final DoublePredicate test)

If a value is present in the OptionalDouble, tests the value using the given predicate and returns the optional if the test returns true or empty otherwise.

public static int
get(final OptionalInt self)

If a value is present in the OptionalInt, returns the value, otherwise throws NoSuchElementException.

public static long
get(final OptionalLong self)

If a value is present in the OptionalLong, returns the value, otherwise throws NoSuchElementException.

public static double
get(final OptionalDouble self)

If a value is present in the OptionalDouble, returns the value, otherwise throws NoSuchElementException.

public static IntStream

Returns:

a Stream for the array
intStream
(final int[]
The array, assumed to be unmodified during use
self
)

Returns a sequential IntStream with the specified array as its source.

public static StringBuilder

Returns:

the StringBuilder on which this operation was invoked
leftShift
(final StringBuilder
a StringBuilder
self
,
final Object
a value to append
value
)

Overloads the left shift operator to provide an easy way to append multiple objects as string representations to a StringBuilder.

public static LongStream

Returns:

a Stream for the array
longStream
(final long[]
The array, assumed to be unmodified during use
self
)

Returns a sequential LongStream with the specified array as its source.

public static <T> OptionalDouble
mapToDouble(final Optional<T> self, final ToDoubleFunction<? super T> mapper)

If a value is present in the OptionalDouble, returns an OptionalDouble consisting of the result of applying the given function to the value or else empty.

public static <T> OptionalInt
mapToInt(final Optional<T> self, final ToIntFunction<? super T> mapper)

If a value is present in the OptionalInt, returns an OptionalInt consisting of the result of applying the given function to the value or else empty.

public static <T> OptionalLong
mapToLong(final Optional<T> self, final ToLongFunction<? super T> mapper)

If a value is present in the OptionalLong, returns an OptionalLong consisting of the result of applying the given function to the value or else empty.

public static <T> Optional<T>
mapToObj(final OptionalInt self, final IntFunction<? extends T> mapper)

If a value is present in the OptionalInt, returns an Optional consisting of the result of applying the given function to the value or else empty.

public static <T> Optional<T>
mapToObj(final OptionalLong self, final LongFunction<? extends T> mapper)

If a value is present in the OptionalLong, returns an Optional consisting of the result of applying the given function to the value or else empty.

public static <T> Optional<T>
mapToObj(final OptionalDouble self, final DoubleFunction<? extends T> mapper)

If a value is present in the OptionalDouble, returns an Optional consisting of the result of applying the given function to the value or else empty.

public static Object

Returns:

the next defined enum from the enum class
next
(final Enum<E extends Enum<E>>
an Enum
self
)

Overloads the ++ operator for enums.

public static <T> Optional<T>
orOptional(Optional<T> self, Supplier<? extends Optional<? extends T>> supplier)

Provide similar functionality to JDK9 or on JDK8.

public static String

Returns:

a String
plus
(final StringBuilder
a StringBuilder
self
,
final String
a String
value
)

Appends a String to this StringBuilder.

public static Object

Returns:

the previous defined enum from the enum class
previous
(final Enum<E extends Enum<E>>
an Enum
self
)

Overloads the -- operator for enums.

public static void
putAt(final StringBuilder
a StringBuilder
self
,
final IntRange
a Range
range
,
final Object
the object that's toString() will be inserted
value
)

Supports the range subscript operator for StringBuilder.

public static void
putAt(final StringBuilder
a StringBuilder
self
,
final EmptyRange<T extends Comparable<T>>
a Range
range
,
final Object
the object that's toString() will be inserted
value
)

Supports the range subscript operator for StringBuilder.

public static int

Returns:

the length of the StringBuilder
size
(final StringBuilder
a StringBuilder
self
)

Deprecated
Provides the standard Groovy size() method for StringBuilder.
public static <T> Stream<T>
stream(final NullObject self)

Returns an empty sequential Stream.

public static <T> Stream<T>
stream(final T self)

Returns a sequential Stream containing a single element.

public static <
The type of the array elements
T
>
Stream<T>

Returns:

a Stream for the array
stream
(final T[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Integer>

Returns:

a Stream for the array
stream
(final int[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Long>

Returns:

a Stream for the array
stream
(final long[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Double>

Returns:

a Stream for the array
stream
(final double[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Character>

Returns:

a Stream for the array
stream
(final char[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Byte>

Returns:

a Stream for the array
stream
(final byte[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Short>

Returns:

a Stream for the array
stream
(final short[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Boolean>

Returns:

a Stream for the array
stream
(final boolean[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static Stream<Float>

Returns:

a Stream for the array
stream
(final float[]
The array, assumed to be unmodified during use
self
)

Returns a sequential Stream with the specified array as its source.

public static <T> Stream<T>
stream(final Enumeration<T> self)

Returns a sequential Stream with the specified element(s) as its source.

public static <T> Stream<T>
stream(final Iterable<T> self)

Returns a sequential Stream with the specified element(s) as its source.

public static <T> Stream<T>
stream(final Iterator<T> self)

Returns a sequential Stream with the specified element(s) as its source.

public static <T> Stream<T>
stream(final Spliterator<T> self)

Returns a sequential Stream with the specified element(s) as its source.

public static <T> Stream<T>
stream(final Optional<T> self)

If a value is present in the Optional, returns a Stream with the value as its source or else an empty stream.

public static IntStream
stream(final OptionalInt self)

If a value is present in the OptionalInt, returns an IntStream with the value as its source or else an empty stream.

public static LongStream
stream(final OptionalLong self)

If a value is present in the OptionalLong, returns a LongStream with the value as its source or else an empty stream.

public static DoubleStream
stream(final OptionalDouble self)

If a value is present in the OptionalDouble, returns a DoubleStream with the value as its source or else an empty stream.

public static <T> T[]
toArray(final Stream<? extends T>
the stream
self
,
final Class<T>
the array element type
type
)

Returns an array containing the elements of the stream.

public static <
the type of element
T
>
List<T>

Returns:

a new java.util.List instance
toList
(final Stream<T>
the stream
self
)

Accumulates the elements of stream into a new List.

public static <
the type of element
T
>
List<T>

Returns:

a new java.util.List instance
toList
(final BaseStream<T, ? extends BaseStream<T, S extends BaseStream<T, S>>>
the java.util.stream.BaseStream
self
)

Accumulates the elements of stream into a new List.

public static <
the type of element
T
>
Set<T>

Returns:

a new java.util.Set instance
toSet
(final Stream<T>
the stream
self
)

Accumulates the elements of stream into a new Set.

public static <
the type of element
T
>
Set<T>

Returns:

a new java.util.Set instance
toSet
(final BaseStream<T, ? extends BaseStream<T, S extends BaseStream<T, S>>>
the java.util.stream.BaseStream
self
)

Accumulates the elements of stream into a new Set.

Inherited from org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport:
cloneSimilarCollectioncloneSimilarMapcloseQuietlycloseWithWarningcreateSimilarArraycreateSimilarCollectioncreateSimilarCollectioncreateSimilarCollectioncreateSimilarListcreateSimilarMapcreateSimilarOrDefaultCollectioncreateSimilarQueuecreateSimilarSetnormaliseIndexsameTypesubListBorderssubListBorderswriteUTF16BomIfRequiredwriteUTF16BomIfRequiredwriteUTF16BomIfRequiredwriteUTF16BomIfRequired