Class DefaultGroovyMethods

java.lang.Object
org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
org.codehaus.groovy.runtime.DefaultGroovyMethods

public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
This class defines new groovy methods which appear on normal JDK classes inside the Groovy environment. Static methods are used with the first parameter being the destination class, i.e. public static String reverse(String self) provides a reverse() method for String.

NOTE: While this class contains many 'public' static methods, it is primarily regarded as an internal class (its internal package name suggests this also). We value backwards compatibility of these methods when used within Groovy but value less backwards compatibility at the Java method call level. I.e. future versions of Groovy may remove or move a method call in this file but would normally aim to keep the method available from within Groovy.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Class[]
     
    static final Class[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    abs(Double number)
    Get the absolute value
    static float
    abs(Float number)
    Get the absolute value
    static long
    abs(Long number)
    Get the absolute value
    static int
    abs(Number number)
    Get the absolute value
    static <T> boolean
    addAll(Collection<T> self, Iterable<? extends T> items)
    Adds all items from the iterable to the Collection.
    static <T> boolean
    addAll(Collection<T> self, Iterator<? extends T> items)
    Adds all items from the iterator to the Collection.
    static <T> boolean
    addAll(Collection<T> self, T[] items)
    Modifies the collection by adding all the elements in the specified array to the collection.
    static <T> boolean
    addAll(List<T> self, int index, T[] items)
    Modifies this list by inserting all the elements in the specified array into the list at the specified position.
    static void
    addShutdownHook(Object self, Closure closure)
    Allows the usage of addShutdownHook without getting the runtime first.
    static Boolean
    and(Boolean left, Boolean right)
    Logical conjunction of two boolean operators.
    static Number
    and(Number left, Number right)
    Bitwise AND together two Numbers.
    static BitSet
    and(BitSet left, BitSet right)
    Bitwise AND together two BitSets.
    static <T> boolean
    any(Iterable<T> self, Closure predicate)
    Iterates over the contents of an iterable, and checks whether a predicate is valid for at least one element.
    static boolean
    any(Object self)
    Iterates over the elements of a collection, and checks whether at least one element is true according to the Groovy Truth.
    static boolean
    any(Object self, Closure predicate)
    Iterates over the contents of an object or collection, and checks whether a predicate is valid for at least one element.
    static <T> boolean
    any(Iterator<T> self, Closure predicate)
    Iterates over the contents of an iterator, and checks whether a predicate is valid for at least one element.
    static <K, V> boolean
    any(Map<K,V> self, Closure<?> predicate)
    Iterates over the entries of a map, and checks whether a predicate is valid for at least one entry.
    static <T> boolean
    any(T[] self, Closure predicate)
    Iterates over the contents of an Array, and checks whether a predicate is valid for at least one element.
    static boolean
    asBoolean(boolean[] array)
    Coerces a boolean array to a boolean value.
    static boolean
    asBoolean(byte[] array)
    Coerces a byte array to a boolean value.
    static boolean
    asBoolean(char[] array)
    Coerces a char array to a boolean value.
    static boolean
    asBoolean(double[] array)
    Coerces a double array to a boolean value.
    static boolean
    asBoolean(float[] array)
    Coerces a float array to a boolean value.
    static boolean
    asBoolean(int[] array)
    Coerces an int array to a boolean value.
    static boolean
    asBoolean(long[] array)
    Coerces a long array to a boolean value.
    static boolean
    asBoolean(short[] array)
    Coerces a short array to a boolean value.
    static boolean
    Coerce a Boolean instance to a boolean value.
    static boolean
    asBoolean(Character character)
    Coerce a character to a boolean value.
    static boolean
    asBoolean(Double object)
    Coerce a Double instance to a boolean value.
    static boolean
    asBoolean(Float object)
    Coerce a Float instance to a boolean value.
    static boolean
    asBoolean(Number number)
    Coerce a number to a boolean value.
    static boolean
    asBoolean(Object object)
    Coerce an object instance to a boolean value.
    static boolean
    asBoolean(Object[] array)
    Coerce an Object array to a boolean value.
    static boolean
    asBoolean(Collection collection)
    Coerce a collection instance to a boolean value.
    static boolean
    asBoolean(Enumeration enumeration)
    Coerce an enumeration instance to a boolean value.
    static boolean
    asBoolean(Iterator iterator)
    Coerce an iterator instance to a boolean value.
    static boolean
    Coerce a map instance to a boolean value.
    static <T> Collection<T>
    Converts this Iterable to a Collection.
    static <T> Collection<T>
    A convenience method for creating an immutable Collection.
    static <T> List<T>
    asImmutable(List<T> self)
    A convenience method for creating an immutable List.
    static <K, V> Map<K,V>
    asImmutable(Map<K,V> self)
    A convenience method for creating an immutable Map.
    static <T> Set<T>
    asImmutable(Set<T> self)
    A convenience method for creating an immutable Set.
    static <K, V> SortedMap<K,V>
    A convenience method for creating an immutable SortedMap.
    static <T> SortedSet<T>
    A convenience method for creating an immutable SortedSet.
    static <T> List<T>
    asList(Iterable<T> self)
    Converts this Iterable to a List.
    static <T> List<T>
    asReversed(List<T> self)
    Creates a view list with reversed order, and the order of original list will not change.
    static <T> NavigableSet<T>
    Creates a reverse order view of the set.
    static String
    Get the detail information of Throwable instance's stack trace
    static <T> Collection<T>
    A convenience method for creating a synchronized Collection.
    static <T> List<T>
    A convenience method for creating a synchronized List.
    static <K, V> Map<K,V>
    asSynchronized(Map<K,V> self)
    A convenience method for creating a synchronized Map.
    static <T> Set<T>
    A convenience method for creating a synchronized Set.
    static <K, V> SortedMap<K,V>
    A convenience method for creating a synchronized SortedMap.
    static <T> SortedSet<T>
    A convenience method for creating a synchronized SortedSet.
    static <T> T
    asType(Closure impl, Class<T> type)
    Coerces the closure to an implementation of the given class.
    static <T> T
    asType(Iterable iterable, Class<T> clazz)
    Converts the given iterable to another type.
    static <T> T
    asType(Number self, Class<T> c)
    Transform this number to the given type, using the 'as' operator.
    static <T> T
    asType(Object[] ary, Class<T> clazz)
    Converts the given array to either a List, Set, or SortedSet.
    static <T> T
    asType(Object obj, Class<T> type)
    Converts a given object to a type.
    static <T> T
    asType(Collection col, Class<T> clazz)
    Converts the given collection to another type.
    static <T> T
    asType(Map map, Class<T> clazz)
    Coerces this map to the given type, using the map's keys as the public method names, and values as the implementation.
    static <T> Collection<T>
    Creates an unmodifiable view of a Collection.
    static <T> List<T>
    Creates an unmodifiable view of a List.
    static <K, V> Map<K,V>
    asUnmodifiable(Map<K,V> self)
    Creates an unmodifiable view of a Map.
    static <T> Set<T>
    Creates an unmodifiable view of a Set.
    static <K, V> SortedMap<K,V>
    Creates an unmodifiable view of a SortedMap.
    static <T> SortedSet<T>
    Creates an unmodifiable view of a SortedSet.
    static BigDecimal
    average(byte[] self)
    Calculates the average of the bytes in the array.
    static double
    average(double[] self)
    Calculates the average of the doubles in the array.
    static double
    average(float[] self)
    Calculates the average of the floats in the array.
    static BigDecimal
    average(int[] self)
    Calculates the average of the ints in the array.
    static BigDecimal
    average(long[] self)
    Calculates the average of the longs in the array.
    static BigDecimal
    average(short[] self)
    Calculates the average of the shorts in the array.
    static Object
    average(Iterable<?> self)
    Averages the items in an Iterable.
    static <T> Object
    average(Iterable<T> self, Closure closure)
    Averages the result of applying a closure to each item of an Iterable.
    static Object
    average(Object[] self)
    Averages the items in an array.
    static Object
    average(Iterator<?> self)
    Averages the items from an Iterator.
    static <T> Object
    average(Iterator<T> self, Closure closure)
    Averages the result of applying a closure to each item returned from an iterator.
    static <T> Object
    average(T[] self, Closure closure)
    Averages the result of applying a closure to each item of an array.
    static Number
    Bitwise NEGATE a Number.
    static BitSet
    Bitwise NEGATE a BitSet.
    static <T> BufferedIterator<T>
    buffered(Iterator<T> self)
    Returns a BufferedIterator that allows examining the next element without consuming it.
    static <T> BufferedIterator<T>
    Returns a BufferedIterator that allows examining the next element without consuming it.
    static <T> BufferedIterator<T>
    Returns a BufferedIterator that allows examining the next element without consuming it.
    protected static <T> T
    callClosureForLine(Closure<T> closure, String line, int counter)
     
    protected static <T, K, V> T
    callClosureForMapEntry(Closure<T> closure, Map.Entry<K,V> entry)
     
    protected static <T, K, V> T
    callClosureForMapEntryAndCounter(Closure<T> closure, Map.Entry<K,V> entry, int counter)
     
    static <T> List<List<T>>
    chop(Iterable<T> self, int... chopSizes)
    Chops the Iterable into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    static <T> List<List<T>>
    chop(Iterator<T> self, int... chopSizes)
    Chops the iterator items into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    static <T> List<List<T>>
    chop(T[] self, int... chopSizes)
    Chops the array into pieces, returning lists with sizes corresponding to the supplied chop sizes.
    static <T> List<List<T>>
    collate(Iterable<T> self, int size)
    Collates this iterable into sub-lists of length size.
    static <T> List<List<T>>
    collate(Iterable<T> self, int size, boolean keepRemainder)
    Collates this iterable into sub-lists of length size.
    static <T> List<List<T>>
    collate(Iterable<T> self, int size, int step)
    Collates this iterable into sub-lists of length size stepping through the code step elements for each subList.
    static <T> List<List<T>>
    collate(Iterable<T> self, int size, int step, boolean keepRemainder)
    Collates this iterable into sub-lists of length size stepping through the code step elements for each sub-list.
    static <T> List<List<T>>
    collate(T[] self, int size)
    Collates an array.
    static <T> List<List<T>>
    collate(T[] self, int size, boolean keepRemainder)
    Collates this array into sub-lists.
    static <T> List<List<T>>
    collate(T[] self, int size, int step)
    Collates an array into sub-lists.
    static <T> List<List<T>>
    collate(T[] self, int size, int step, boolean keepRemainder)
    Collates this array into sub-lists.
    static <E, T, C extends Collection<T>>
    C
    collect(E[] self, C collector, Closure<? extends T> transform)
    Iterates through this Array transforming each item into a new value using the transform closure and adding it to the supplied collector.
    static <E, T> List<T>
    collect(E[] self, Closure<T> transform)
    Iterates through this Array transforming each item into a new value using the transform closure, returning a list of transformed values.
    static <E, T, C extends Collection<T>>
    C
    collect(Iterable<E> self, C collector, Closure<? extends T> transform)
    Iterates through this collection transforming each value into a new value using the transform closure and adding it to the supplied collector.
    static <E, T> List<T>
    collect(Iterable<E> self, Closure<T> transform)
    Iterates through this Iterable transforming each entry into a new value using the transform closure returning a list of transformed values.
    static <T> List<T>
    collect(Iterable<T> self)
    Iterates through this collection transforming each entry into a new value using Closure.IDENTITY as a transformer, basically returning a list of items copied from the original collection.
    static Collection
    Iterates through this aggregate Object transforming each item into a new value using Closure.IDENTITY as a transformer, basically returning a list of items copied from the original object.
    static <T, C extends Collection<T>>
    C
    collect(Object self, C collector, Closure<? extends T> transform)
    Iterates through this aggregate Object transforming each item into a new value using the transform closure and adding it to the supplied collector.
    static <T> List<T>
    collect(Object self, Closure<T> transform)
    Iterates through this aggregate Object transforming each item into a new value using the transform closure, returning a list of transformed values.
    static <E, T, C extends Collection<T>>
    C
    collect(Iterator<E> self, C collector, Closure<? extends T> transform)
    Iterates through this Iterator transforming each item into a new value using the transform closure and adding it to the supplied collector.
    static <E, T> List<T>
    collect(Iterator<E> self, Closure<T> transform)
    Iterates through this Iterator transforming each item into a new value using the transform closure, returning a list of transformed values.
    static <T, K, V, C extends Collection<T>>
    C
    collect(Map<K,V> self, C collector, Closure<? extends T> transform)
    Iterates through this Map transforming each map entry into a new value using the transform closure returning the collector with all transformed values added to it.
    static <T, K, V> List<T>
    collect(Map<K,V> self, Closure<T> transform)
    Iterates through this Map transforming each map entry into a new value using the transform closure returning a list of transformed values.
    static <K, V, E> Map<K,V>
    collectEntries(E[] self)
    A variant of collectEntries using the identity closure as the transform.
    static <K, V, E> Map<K,V>
    collectEntries(E[] self, Closure<?> transform)
    Iterates through this array transforming each item using the transform closure and returning a map of the resulting transformed entries.
    static <K, V, E> Map<K,V>
    collectEntries(E[] self, Map<K,V> collector)
    A variant of collectEntries using the identity closure as the transform.
    static <K, V, E> Map<K,V>
    collectEntries(E[] self, Map<K,V> collector, Closure<?> transform)
    Iterates through this array transforming each item using the transform closure and returning a map of the resulting transformed entries.
    static <K, V> Map<K,V>
    A variant of collectEntries for Iterable objects using the identity closure as the transform.
    static <K, V> Map<K,V>
    collectEntries(Iterable<?> self, Map<K,V> collector)
    A variant of collectEntries for Iterables using the identity closure as the transform and a supplied map as the destination of transformed entries.
    static <K, V, E> Map<K,V>
    collectEntries(Iterable<E> self, Closure<?> transform)
    Iterates through this Iterable transforming each item using the transform closure and returning a map of the resulting transformed entries.
    static <K, V, E> Map<K,V>
    collectEntries(Iterable<E> self, Map<K,V> collector, Closure<?> transform)
    Iterates through this Iterable transforming each item using the closure as a transformer into a map entry, returning the supplied map with all the transformed entries added to it.
    static <K, V> Map<K,V>
    A variant of collectEntries for Iterators using the identity closure as the transform.
    static <K, V> Map<K,V>
    collectEntries(Iterator<?> self, Map<K,V> collector)
    A variant of collectEntries for Iterators using the identity closure as the transform and a supplied map as the destination of transformed entries.
    static <K, V, E> Map<K,V>
    collectEntries(Iterator<E> self, Closure<?> transform)
    A variant of collectEntries for Iterators.
    static <K, V, E> Map<K,V>
    collectEntries(Iterator<E> self, Map<K,V> collector, Closure<?> transform)
    A variant of collectEntries for Iterators using a supplied map as the destination of transformed entries.
    static <K, V, X, Y> Map<K,V>
    collectEntries(Map<X,Y> self, Closure<?> transform)
    Iterates through this Map transforming each entry using the transform closure and returning a map of the transformed entries.
    static <K, V, X, Y> Map<K,V>
    collectEntries(Map<X,Y> self, Map<K,V> collector, Closure<?> transform)
    Iterates through this Map transforming each map entry using the transform closure returning a map of the transformed entries.
    static <T, E, C extends Collection<T>>
    C
    collectMany(E[] self, C collector, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source array to a collection and concatenates (flattens) the resulting collections into a single list.
    static <T, E> List<T>
    collectMany(E[] self, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source array to a collection and concatenates (flattens) the resulting collections into a single list.
    static <T, E, C extends Collection<T>>
    C
    collectMany(Iterable<E> self, C collector, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source collection to a result collection and concatenates (flattens) the resulting collections adding them into the collector.
    static <T, E> List<T>
    collectMany(Iterable<E> self, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source Iterable to a collection and concatenates (flattens) the resulting collections into a single list.
    static <T, E, C extends Collection<T>>
    C
    collectMany(Iterator<E> self, C collector, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source iterator to a collection and concatenates (flattens) the resulting collections into a single list.
    static <T, E> List<T>
    collectMany(Iterator<E> self, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source iterator to a collection and concatenates (flattens) the resulting collections into a single list.
    static <T, K, V, C extends Collection<T>>
    C
    collectMany(Map<K,V> self, C collector, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source map to a result collection and concatenates (flattens) the resulting collections adding them into the collector.
    static <T, K, V> List<T>
    collectMany(Map<K,V> self, Closure<? extends Collection<? extends T>> projection)
    Projects each item from a source map to a result collection and concatenates (flattens) the resulting collections adding them into a collection.
    static <T, K, V> Collection<T>
    collectMany$$bridge(Map<K,V> self, Closure<? extends Collection<? extends T>> projection)
    Deprecated.
    static <C extends Collection>
    C
    collectNested(Iterable self, C collector, Closure transform)
    Recursively iterates through this Iterable transforming each non-Collection value into a new value using the transform closure.
    static List
    collectNested(Iterable self, Closure transform)
    Recursively iterates through this Iterable transforming each non-Collection value into a new value using the closure as a transformer.
    static List
    collectNested(Collection self, Closure transform)
    Recursively iterates through this collection transforming each non-Collection value into a new value using the closure as a transformer.
    static List
    Adds GroovyCollections#combinations(Iterable) as a method on Iterables.
    static List
    combinations(Iterable self, Closure<?> function)
    Adds GroovyCollections#combinations(Iterable, Closure) as a method on collections.
    static int
    Compare two Characters.
    static int
    compareTo(Character left, Number right)
    Compare a Character and a Number.
    static int
    compareTo(Number left, Character right)
    Compare a Number and a Character.
    static int
    compareTo(Number left, Number right)
    Compare two Numbers.
    static boolean
    contains(boolean[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(byte[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(char[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(double[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(float[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(int[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(long[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(short[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    contains(Iterable self, Object item)
    Returns true if this iterable contains the item.
    static boolean
    contains(Object[] self, Object value)
    Checks whether the array contains the given value.
    static boolean
    containsAll(Iterable<?> self, Object[] items)
    Returns true if this iterable contains all the elements in the specified array.
    static Number
    count(boolean[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(byte[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(char[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(double[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(float[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(int[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(long[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static Number
    count(short[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static <T, E extends Number>
    E
    count(Iterable<T> self, E initialCount, Closure closure)
    Counts the number of occurrences which satisfy the given closure from inside this Iterable.
    static <T> Number
    count(Iterable<T> self, Closure closure)
    Counts the number of occurrences which satisfy the given closure from inside this Iterable.
    static Number
    count(Iterable self, Object value)
    Counts the number of occurrences of the given value inside this Iterable.
    static Number
    count(Object[] self, Object value)
    Counts the number of occurrences of the given value inside this array.
    static <T, E extends Number>
    E
    count(Iterator<T> self, E initialCount, Closure closure)
    Counts the number of occurrences which satisfy the given closure from the items within this Iterator, adding the count to the initial count.
    static <T> Number
    count(Iterator<T> self, Closure closure)
    Counts the number of occurrences which satisfy the given closure from the items within this Iterator.
    static Number
    count(Iterator self, Object value)
    Counts the number of occurrences of the given value from the items within this Iterator.
    static <K, V, E extends Number>
    E
    count(Map<K,V> self, E initialCount, Closure<?> closure)
    Counts the number of occurrences which satisfy the given closure from inside this map.
    static <K, V> Number
    count(Map<K,V> self, Closure<?> closure)
    Counts the number of occurrences which satisfy the given closure from inside this map.
    static <T> Number
    count(T[] self, Closure closure)
    Counts the number of occurrences which satisfy the given closure from inside this array.
    static <K, E> Map<K,Integer>
    countBy(E[] self, Closure<K> closure)
    Sorts all array members into groups determined by the supplied mapping closure and counts the group size.
    static <K, E> Map<K,Integer>
    countBy(Iterable<E> self, Closure<K> closure)
    Sorts all collection members into groups determined by the supplied mapping closure and counts the group size.
    static <K, E> Map<K,Integer>
    countBy(Iterator<E> self, Closure<K> closure)
    Sorts all iterator items into groups determined by the supplied mapping closure and counts the group size.
    static <K, U, V> Map<K,Integer>
    countBy(Map<U,V> self, Closure<K> closure)
    Groups the members of a map into groups determined by the supplied mapping closure and counts the frequency of the created groups.
    static boolean
    disjoint(Iterable left, Iterable right)
    Returns true if the intersection of two iterables is empty.
    static Number
    div(Character left, Character right)
    Divide one Character by another.
    static Number
    div(Character left, Number right)
    Divide a Character by a Number.
    static Number
    div(Number left, Character right)
    Divide a Number by a Character.
    static void
    downto(double self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(float self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(long self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(Double self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(Float self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(Long self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(Number self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(BigDecimal self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static void
    downto(BigInteger self, Number to, Closure closure)
    Iterates from this number down to the given number, inclusive, decrementing by one each time.
    static <T> Collection<T>
    drop(Iterable<T> self, int num)
    Drops the given number of elements from the head of this Iterable.
    static <T> Iterator<T>
    drop(Iterator<T> self, int num)
    Drops the given number of elements from the head of this iterator if they are available.
    static <T> List<T>
    drop(List<T> self, int num)
    Drops the given number of elements from the head of this List.
    static <K, V> Map<K,V>
    drop(Map<K,V> self, int num)
    Drops the given number of key/value pairs from the head of this map if they are available.
    static <T> SortedSet<T>
    drop(SortedSet<T> self, int num)
    Drops the given number of elements from the head of this List.
    static <T> T[]
    drop(T[] self, int num)
    Drops the given number of elements from the head of this array if they are available.
    static <T> Collection<T>
    dropRight(Iterable<T> self, int num)
    Drops the given number of elements from the tail of this Iterable.
    static <T> Iterator<T>
    dropRight(Iterator<T> self, int num)
    Drops the given number of elements from the tail of this Iterator.
    static <T> List<T>
    dropRight(List<T> self, int num)
    Drops the given number of elements from the tail of this List.
    static <T> SortedSet<T>
    dropRight(SortedSet<T> self, int num)
    Drops the given number of elements from the tail of this SortedSet.
    static <T> T[]
    dropRight(T[] self, int num)
    Drops the given number of elements from the tail of this array if they are available.
    static <T> Collection<T>
    dropWhile(Iterable<T> self, Closure condition)
    Returns a suffix of this Iterable where elements are dropped from the front while the given closure evaluates to true.
    static <T> Iterator<T>
    dropWhile(Iterator<T> self, Closure<?> condition)
    Creates an Iterator that returns a suffix of the elements from an original Iterator.
    static <T> List<T>
    dropWhile(List<T> self, Closure condition)
    Returns a suffix of this List where elements are dropped from the front while the given Closure evaluates to true.
    static <K, V> Map<K,V>
    dropWhile(Map<K,V> self, Closure condition)
    Create a suffix of the given Map by dropping as many entries as possible from the front of the original Map such that calling the given closure condition evaluates to true when passed each of the dropped entries (or key/value pairs).
    static <T> SortedSet<T>
    dropWhile(SortedSet<T> self, Closure condition)
    Returns a suffix of this SortedSet where elements are dropped from the front while the given Closure evaluates to true.
    static <T> T[]
    dropWhile(T[] self, Closure<?> condition)
    Create a suffix of the given array by dropping as many elements as possible from the front of the original array such that calling the given closure condition evaluates to true when passed each of the dropped elements.
    static String
    dump(Object self)
    Generates a detailed dump string of an object showing its class, hashCode and all accessible fields.
    static <T> Iterable<T>
    each(Iterable<T> self, Closure closure)
    Iterates through an Iterable, passing each item to the given closure.
    static <T> Collection<T>
    each(Collection<T> self, Closure closure)
    Iterates through a Collection, passing each item to the given closure.
    static <T> Iterator<T>
    each(Iterator<T> self, Closure closure)
    Iterates through an Iterator, passing each item to the given closure.
    static <T> List<T>
    each(List<T> self, Closure closure)
    Iterates through a List, passing each item to the given closure.
    static <K, V> Map<K,V>
    each(Map<K,V> self, Closure<?> closure)
    Allows a Map to be iterated through using a closure.
    static <T> Set<T>
    each(Set<T> self, Closure closure)
    Iterates through a Set, passing each item to the given closure.
    static <T> SortedSet<T>
    each(SortedSet<T> self, Closure closure)
    Iterates through a SortedSet, passing each item to the given closure.
    static <T> T[]
    each(T[] self, Closure closure)
    Iterates through an array passing each array entry to the given closure.
    static <T> T
    each(T self, Closure closure)
    Iterates through an aggregate type or data structure, passing each item to the given closure.
    static void
    eachByte(byte[] self, Closure closure)
    Traverse through each byte of this byte array.
    static void
    eachByte(Byte[] self, Closure closure)
    Traverse through each byte of this Byte array.
    static void
    eachCombination(Iterable self, Closure<?> function)
    Applies a function on each combination of the input lists.
    static <T> Iterator<List<T>>
    eachPermutation(Iterable<T> self, Closure closure)
    Iterates over all permutations of a collection, running a closure for each iteration.
    static <T> Iterable<T>
    eachWithIndex(Iterable<T> self, Closure closure)
    Iterates through an iterable type, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <T> Collection<T>
    eachWithIndex(Collection<T> self, Closure closure)
    Iterates through a Collection, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <T> Iterator<T>
    eachWithIndex(Iterator<T> self, Closure closure)
    Iterates through an iterator type, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <T> List<T>
    eachWithIndex(List<T> self, Closure closure)
    Iterates through a List, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <K, V> Map<K,V>
    eachWithIndex(Map<K,V> self, Closure<?> closure)
    Allows a Map to be iterated through using a closure.
    static <T> Set<T>
    eachWithIndex(Set<T> self, Closure closure)
    Iterates through a Set, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <T> SortedSet<T>
    eachWithIndex(SortedSet<T> self, Closure closure)
    Iterates through a SortedSet, passing each item and the item's index (a counter starting at zero) to the given closure.
    static <T> T[]
    eachWithIndex(T[] self, Closure closure)
    Iterates through an array, passing each array element and the element's index (a counter starting at zero) to the given closure.
    static <T> T
    eachWithIndex(T self, Closure closure)
    Iterates through an aggregate type or data structure, passing each item and the item's index (a counter starting at zero) to the given closure.
    static boolean
    equals(int[] left, int[] right)
    Compare the contents of this array to the contents of the given array.
    static boolean
    equals(Object[] left, List right)
    Determines if the contents of this array are equal to the contents of the given list, in the same order.
    static boolean
    equals(List left, Object[] right)
    Determines if the contents of this list are equal to the contents of the given array in the same order.
    static boolean
    equals(List left, List right)
    Compare the contents of two Lists.
    static boolean
    equals(Map self, Map other)
    Compares two Maps treating coerced numerical values as identical.
    static <T> boolean
    equals(Set<T> self, Set<T> other)
    Compare the contents of two Sets for equality using Groovy's coercion rules.
    static boolean
    Compares this object against the specified object returning the same result as Double.equals(Object) but returning true if this object and the specified object are both zero and negative zero respectively or vice versa.
    static boolean
    Compares this object against the specified object returning the same result as Float.equals(Object) but returning true if this object and the specified object are both zero and negative zero respectively or vice versa.
    static <T> boolean
    every(Iterable<T> self, Closure predicate)
    Used to determine if the given predicate closure is valid (i.e.
    static boolean
    every(Object self)
    Iterates over every element of a collection, and checks whether all elements are true according to the Groovy Truth.
    static boolean
    every(Object self, Closure predicate)
    Used to determine if the given predicate closure is valid (i.e.
    static <T> boolean
    every(Iterator<T> self, Closure predicate)
    Used to determine if the given predicate closure is valid (i.e.
    static <K, V> boolean
    every(Map<K,V> self, Closure predicate)
    Iterates over the entries of a map, and checks whether a predicate is valid for all entries.
    static <T> boolean
    every(T[] self, Closure predicate)
    Used to determine if the given predicate closure is valid (i.e.
    static Object
    find(Object self)
    Finds the first item matching the IDENTITY Closure (i.e. matching Groovy truth).
    static Object
    find(Object self, Closure closure)
    Finds the first value matching the closure condition.
    static <T> T
    find(Collection<T> self)
    Finds the first item matching the IDENTITY Closure (i.e. matching Groovy truth).
    static <T> T
    find(Collection<T> self, Closure closure)
    Finds the first value matching the closure condition.
    static <K, V> Map.Entry<K,V>
    find(Map<K,V> self, Closure<?> closure)
    Finds the first entry matching the closure condition.
    static <T> T
    find(T[] self, Closure condition)
    Finds the first element in the array that matches the given closure condition.
    static List
    Finds all items matching the IDENTITY Closure (i.e. matching Groovy truth).
    static List
    findAll(Object self, Closure closure)
    Finds all items matching the closure condition.
    static <T> Collection<T>
    Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
    static <T> Collection<T>
    findAll(Collection<T> self, Closure closure)
    Finds all values matching the closure condition.
    static <T> List<T>
    findAll(List<T> self)
    Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
    static <T> List<T>
    findAll(List<T> self, Closure closure)
    Finds all values matching the closure condition.
    static <K, V> Map<K,V>
    findAll(Map<K,V> self, Closure closure)
    Finds all entries matching the closure condition.
    static <T> Set<T>
    findAll(Set<T> self)
    Finds the items matching the IDENTITY Closure (i.e. matching Groovy truth).
    static <T> Set<T>
    findAll(Set<T> self, Closure closure)
    Finds all values matching the closure condition.
    static <T> List<T>
    findAll(T[] self)
    Finds the elements of the array matching the IDENTITY Closure (i.e. matching Groovy truth).
    static <T> List<T>
    findAll(T[] self, Closure condition)
    Finds all elements of the array matching the given Closure condition.
    static Collection
    Deprecated.
    static Collection
    findAll$$bridge(Object self, Closure closure)
    Deprecated.
    static <T> Collection<T>
    findAll$$bridge(T[] self)
    Deprecated.
    static <T> Collection<T>
    findAll$$bridge(T[] self, Closure condition)
    Deprecated.
    static <T> int
    findIndexOf(Iterable<T> self, int startIndex, Closure condition)
    Iterates over the elements of an Iterable, starting from a specified startIndex, and returns the index of the first item that satisfies the condition specified by the closure.
    static <T> int
    findIndexOf(Iterable<T> self, Closure condition)
    Iterates over the elements of an Iterable and returns the index of the first item that satisfies the condition specified by the closure.
    static int
    findIndexOf(Object self, int startIndex, Closure condition)
    Iterates over the elements of an aggregate of items, starting from a specified startIndex, and returns the index of the first item that matches the condition specified in the closure.
    static int
    findIndexOf(Object self, Closure condition)
    Iterates over the elements of an aggregate of items and returns the index of the first item that matches the condition specified in the closure.
    static <T> int
    findIndexOf(Iterator<T> self, int startIndex, Closure condition)
    Iterates over the elements of an Iterator, starting from a specified startIndex, and returns the index of the first item that satisfies the condition specified by the closure.
    static <T> int
    findIndexOf(Iterator<T> self, Closure condition)
    Iterates over the elements of an Iterator and returns the index of the first item that satisfies the condition specified by the closure.
    static <T> int
    findIndexOf(T[] self, int startIndex, Closure condition)
    Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the first item that satisfies the condition specified by the closure.
    static <T> int
    findIndexOf(T[] self, Closure condition)
    Iterates over the elements of an Array and returns the index of the first item that satisfies the condition specified by the closure.
    static <T> List<Number>
    findIndexValues(Iterable<T> self, Closure condition)
    Iterates over the elements of an Iterable and returns the index values of the items that match the condition specified in the closure.
    static <T> List<Number>
    findIndexValues(Iterable<T> self, Number startIndex, Closure condition)
    Iterates over the elements of an Iterable, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.
    static List<Number>
    findIndexValues(Object self, Closure condition)
    Iterates over the elements of an aggregate of items and returns the index values of the items that match the condition specified in the closure.
    static List<Number>
    findIndexValues(Object self, Number startIndex, Closure condition)
    Iterates over the elements of an aggregate of items, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.
    static <T> List<Number>
    findIndexValues(Iterator<T> self, Closure condition)
    Iterates over the elements of an Iterator and returns the index values of the items that match the condition specified in the closure.
    static <T> List<Number>
    findIndexValues(Iterator<T> self, Number startIndex, Closure condition)
    Iterates over the elements of an Iterator, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.
    static <T> List<Number>
    findIndexValues(T[] self, Closure condition)
    Iterates over the elements of an Array and returns the index values of the items that match the condition specified in the closure.
    static <T> List<Number>
    findIndexValues(T[] self, Number startIndex, Closure condition)
    Iterates over the elements of an Array, starting from a specified startIndex, and returns the index values of the items that match the condition specified in the closure.
    static <T> int
    findLastIndexOf(Iterable<T> self, int startIndex, Closure condition)
    Iterates over the elements of an Iterable, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.
    static <T> int
    findLastIndexOf(Iterable<T> self, Closure condition)
    Iterates over the elements of an Iterable and returns the index of the last item that matches the condition specified in the closure.
    static int
    findLastIndexOf(Object self, int startIndex, Closure condition)
    Iterates over the elements of an aggregate of items, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.
    static int
    findLastIndexOf(Object self, Closure condition)
    Iterates over the elements of an aggregate of items and returns the index of the last item that matches the condition specified in the closure.
    static <T> int
    findLastIndexOf(Iterator<T> self, int startIndex, Closure condition)
    Iterates over the elements of an Iterator, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.
    static <T> int
    findLastIndexOf(Iterator<T> self, Closure condition)
    Iterates over the elements of an Iterator and returns the index of the last item that matches the condition specified in the closure.
    static <T> int
    findLastIndexOf(T[] self, int startIndex, Closure condition)
    Iterates over the elements of an Array, starting from a specified startIndex, and returns the index of the last item that matches the condition specified in the closure.
    static <T> int
    findLastIndexOf(T[] self, Closure condition)
    Iterates over the elements of an Array and returns the index of the last item that matches the condition specified in the closure.
    static <S, T, U extends T, V extends T>
    T
    findResult(Iterable<S> self, U defaultResult, Closure<V> condition)
    Iterates through the Iterable calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <T> T
    Iterates through the Iterable stopping once the first non-null result is found and returning that result.
    static <T, U> T
    findResult(Iterable<U> self, Closure<T> condition)
    Iterates through the Iterable calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <T, U extends T, V extends T>
    T
    findResult(Iterable<U> self, V defaultResult)
    Iterates through the Iterable calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static Object
    Treats the object as iterable, iterating through the values it represents and returns the first non-null value, otherwise returns null.
    static Object
    findResult(Object self, Closure condition)
    Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns null.
    static Object
    findResult(Object self, Object defaultResult)
    Treats the object as iterable, iterating through the values it represents and returns the first non-null result, otherwise returns the defaultResult.
    static Object
    findResult(Object self, Object defaultResult, Closure condition)
    Treats the object as iterable, iterating through the values it represents and returns the first non-null result obtained from calling the closure, otherwise returns the defaultResult.
    static <S, T, U extends T, V extends T>
    T
    findResult(Iterator<S> self, U defaultResult, Closure<V> condition)
    Iterates through the Iterator calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <T> T
    Iterates through the Iterator stopping once the first non-null result is found and returning that result.
    static <T, U> T
    findResult(Iterator<U> self, Closure<T> condition)
    Iterates through the Iterator calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <T, U extends T, V extends T>
    T
    findResult(Iterator<U> self, V defaultResult)
    Iterates through the Iterator stopping once the first non-null result is found and returning that result.
    static <T, U extends T, V extends T, A, B>
    T
    findResult(Map<A,B> self, U defaultResult, Closure<V> condition)
    Returns the first non-null closure result found by passing each map entry to the closure, otherwise the defaultResult is returned.
    static <T, K, V> T
    findResult(Map<K,V> self, Closure<T> condition)
    Returns the first non-null closure result found by passing each map entry to the closure, otherwise null is returned.
    static <S, T> T
    findResult(S[] self, Closure<T> condition)
    Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <S, T, U extends T, V extends T>
    T
    findResult(S[] self, U defaultResult, Closure<V> condition)
    Iterates through the Array calling the given closure condition for each item but stopping once the first non-null result is found and returning that result.
    static <T> T
    findResult(T[] self)
    Iterates through the Array stopping once the first non-null result is found and returning that result.
    static <T, U extends T, V extends T>
    T
    findResult(U[] self, V defaultResult)
    Iterates through the Array stopping once the first non-null result is found and returning that result.
    static <T> Collection<T>
    Iterates through the Iterable collecting any non-null results.
    static <T, U> Collection<T>
    findResults(Iterable<U> self, Closure<T> filteringTransform)
    Iterates through the Iterable transforming items using the supplied closure and collecting any non-null results.
    static <T> Collection<T>
    Iterates through the Iterator collecting any non-null results.
    static <T, U> Collection<T>
    findResults(Iterator<U> self, Closure<T> filteringTransform)
    Iterates through the Iterator transforming items using the supplied closure and collecting any non-null results.
    static <T, K, V> Collection<T>
    findResults(Map<K,V> self, Closure<T> filteringTransform)
    Iterates through the map transforming items using the supplied closure and collecting any non-null results.
    static <T> Collection<T>
    findResults(T[] self)
    Iterates through the Array collecting any non-null results.
    static <T, U> Collection<T>
    findResults(U[] self, Closure<T> filteringTransform)
    Iterates through the Array transforming items using the supplied closure and collecting any non-null results.
    static <T> T
    first(Iterable<T> self)
    Returns the first item from the Iterable.
    static <T> T
    first(List<T> self)
    Returns the first item from the List.
    static <T> T
    first(T[] self)
    Returns the first item from the array.
    static Collection
    flatten(boolean[] self)
    Flatten an array.
    static Collection
    flatten(byte[] self)
    Flatten an array.
    static Collection
    flatten(char[] self)
    Flatten an array.
    static Collection
    flatten(double[] self)
    Flatten an array.
    static Collection
    flatten(float[] self)
    Flatten an array.
    static Collection
    flatten(int[] self)
    Flatten an array.
    static Collection
    flatten(long[] self)
    Flatten an array.
    static Collection
    flatten(short[] self)
    Flatten an array.
    static Collection<?>
    flatten(Iterable<?> self)
    Flatten an Iterable.
    static <T> Collection<T>
    flatten(Iterable<T> self, Closure<? extends T> flattenUsing)
    Flatten an Iterable.
    static Collection
    flatten(Object[] self)
    Flatten an array.
    static Collection<?>
    Flatten a Collection.
    static List<?>
    flatten(List<?> self)
    Flatten a List.
    static Set<?>
    flatten(Set<?> self)
    Flatten a Set.
    static SortedSet<?>
    flatten(SortedSet<?> self)
    Flatten a SortedSet.
    static <K, V> V
    get(Map<K,V> map, K key, V defaultValue)
    Looks up an item in a Map for the given key and returns the corresponding value.
    static List<Boolean>
    getAt(boolean[] array, IntRange range)
    Support the subscript operator with an IntRange for a boolean array
    static List<Boolean>
    getAt(boolean[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a byte array
    static List<Boolean>
    getAt(boolean[] array, Range range)
    Support the subscript operator with a range for a boolean array
    static List<Boolean>
    getAt(boolean[] array, Collection indices)
    Support the subscript operator with a collection for a boolean array
    static List<Byte>
    getAt(byte[] array, IntRange range)
    Support the subscript operator with an IntRange for a byte array
    static List<Byte>
    getAt(byte[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a byte array
    static List<Byte>
    getAt(byte[] array, Range range)
    Support the subscript operator with a range for a byte array
    static List<Byte>
    getAt(byte[] array, Collection indices)
    Support the subscript operator with a collection for a byte array
    static List<Character>
    getAt(char[] array, IntRange range)
    Support the subscript operator with an IntRange for a char array
    static List<Character>
    getAt(char[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a char array
    static List<Character>
    getAt(char[] array, Range range)
    Support the subscript operator with a range for a char array
    static List<Character>
    getAt(char[] array, Collection indices)
    Support the subscript operator with a collection for a char array
    static List<Double>
    getAt(double[] array, IntRange range)
    Support the subscript operator with an IntRange for a double array
    static List<Double>
    getAt(double[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a double array
    static List<Double>
    getAt(double[] array, Range range)
    Support the subscript operator with a range for a double array
    static List<Double>
    getAt(double[] array, Collection indices)
    Support the subscript operator with a collection for a double array
    static List<Float>
    getAt(float[] array, IntRange range)
    Support the subscript operator with an IntRange for a float array
    static List<Float>
    getAt(float[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a float array
    static List<Float>
    getAt(float[] array, Range range)
    Support the subscript operator with a range for a float array
    static List<Float>
    getAt(float[] array, Collection indices)
    Support the subscript operator with a collection for a float array
    static List<Integer>
    getAt(int[] array, IntRange range)
    Support the subscript operator with an IntRange for an int array
    static List<Integer>
    getAt(int[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for an int array
    static List<Integer>
    getAt(int[] array, Range range)
    Support the subscript operator with a range for an int array
    static List<Integer>
    getAt(int[] array, Collection indices)
    Support the subscript operator with a collection for an int array
    static List<Long>
    getAt(long[] array, IntRange range)
    Support the subscript operator with an IntRange for a long array
    static List<Long>
    getAt(long[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a long array
    static List<Long>
    getAt(long[] array, Range range)
    Support the subscript operator with a range for a long array
    static List<Long>
    getAt(long[] array, Collection indices)
    Support the subscript operator with a collection for a long array
    static List<Short>
    getAt(short[] array, IntRange range)
    Support the subscript operator with an IntRange for a short array
    static List<Short>
    getAt(short[] array, ObjectRange range)
    Support the subscript operator with an ObjectRange for a short array
    static List<Short>
    getAt(short[] array, Range range)
    Support the subscript operator with a range for a short array
    static List<Short>
    getAt(short[] array, Collection indices)
    Support the subscript operator with a collection for a short array
    static <T> List<T>
    getAt(ListWithDefault<T> self, EmptyRange range)
    Support the range subscript operator for an eager or lazy List.
    static <T> List<T>
    getAt(ListWithDefault<T> self, Range range)
    Support the range subscript operator for an eager or lazy List.
    static <T> List<T>
    getAt(ListWithDefault<T> self, Collection indices)
    Select a List of items from an eager or lazy List using a Collection to identify the indices to be selected.
    static <T> T
    getAt(Iterable<T> self, int idx)
    Support the subscript operator for an Iterable.
    static Object
    getAt(Object self, String property)
    Allows the subscript operator to be used to lookup dynamic property values.
    static boolean
    getAt(BitSet self, int index)
    Support the subscript operator for a Bitset
    static BitSet
    getAt(BitSet self, IntRange range)
    Support retrieving a subset of a BitSet using a Range
    static List
    getAt(Collection coll, String property)
    Support the subscript operator for Collection.
    static <T> T
    getAt(Iterator<T> self, int idx)
    Support the subscript operator for an Iterator.
    static <T> T
    getAt(List<T> self, int idx)
    Support the subscript operator for a List.
    static <T> List<T>
    getAt(List<T> self, EmptyRange range)
    Support the range subscript operator for a List.
    static <T> List<T>
    getAt(List<T> self, Range range)
    Support the range subscript operator for a List.
    static <T> T
    getAt(List<T> self, Number idx)
    Support subscript operator for list access.
    static <T> List<T>
    getAt(List<T> self, Collection indices)
    Select a List of items from a List using a Collection to identify the indices to be selected.
    static <K, V> V
    getAt(Map<K,V> self, Object key)
    Support the subscript operator for a Map.
    static <T> List<T>
    getAt(T[] array, EmptyRange range)
     
    static <T> List<T>
    getAt(T[] array, IntRange range)
     
    static <T> List<T>
    getAt(T[] array, ObjectRange range)
     
    static <T> List<T>
    getAt(T[] array, Range range)
    Support the range subscript operator for an Array
    static <T> List<T>
    getAt(T[] self, Collection indices)
    Select a List of items from an array using a Collection to identify the indices to be selected.
    static Groovydoc
    Get runtime groovydoc
    static IntRange
    getIndices(boolean[] self)
    Returns indices of the boolean array.
    static IntRange
    getIndices(byte[] self)
    Returns indices of the byte array.
    static IntRange
    getIndices(char[] self)
    Returns indices of the char array.
    static IntRange
    getIndices(double[] self)
    Returns indices of the double array.
    static IntRange
    getIndices(float[] self)
    Returns indices of the float array.
    static IntRange
    getIndices(int[] self)
    Returns indices of the int array.
    static IntRange
    getIndices(long[] self)
    Returns indices of the long array.
    static IntRange
    getIndices(short[] self)
    Returns indices of the short array.
    static IntRange
    Returns indices of the collection.
    static <T> IntRange
    getIndices(T[] self)
    Returns indices of the array.
    static URL
    Gets the url of the jar file/source file containing the specified class
    static MetaClass
    Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself.
    static MetaClass
    Adds a "metaClass" property to all class objects so you can use the syntax String.metaClass.myMethod = { println "foo" }
    static MetaClass
    Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself.
    Retrieves the list of MetaProperty objects for 'self' and wraps it in a list of PropertyValue objects that additionally provide the value for each property of 'self'.
    static Map
    Convenience method that calls getMetaPropertyValues(java.lang.Object)(self) and provides the data in form of simple key/value pairs, i.e.
    Iterates through the classloader parents until it finds a loader with a class named "org.codehaus.groovy.tools.RootLoader".
    protected static List
    getSubList(List self, List splice)
    Deprecated.
    static Collection
    grep(Object self)
    Iterates over the collection of items which this Object represents and returns each item that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    static Collection
    grep(Object self, Object filter)
    Iterates over the collection of items which this Object represents and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.
    static <T> Collection<T>
    grep(Collection<T> self)
    Iterates over the collection returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    static <T> Collection<T>
    grep(Collection<T> self, Object filter)
    Iterates over the collection of items and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.
    static <T> List<T>
    grep(List<T> self)
    Iterates over the collection returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    static <T> List<T>
    grep(List<T> self, Object filter)
    Iterates over the collection of items and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.
    static <T> Set<T>
    grep(Set<T> self)
    Iterates over the collection returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    static <T> Set<T>
    grep(Set<T> self, Object filter)
    Iterates over the collection of items and returns each item that matches the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.
    static <T> Collection<T>
    grep(T[] self)
    Iterates over the array returning each element that matches using the IDENTITY Closure as a filter - effectively returning all elements which satisfy Groovy truth.
    static <T> Collection<T>
    grep(T[] self, Object filter)
    Iterates over the array of items and returns a collection of items that match the given filter - calling the isCase(java.lang.Object, java.lang.Object) method used by switch statements.
    protected static <K, T> void
    groupAnswer(Map<K,List<T>> answer, T element, K value)
    Groups the current element according to the value
    static <K, T> Map<K,List<T>>
    groupBy(Iterable<T> self, Closure<K> closure)
    Sorts all Iterable members into groups determined by the supplied mapping closure.
    static Map
    groupBy(Iterable self, Object... closures)
    Sorts all Iterable members into (sub)groups determined by the supplied mapping closures.
    static Map
    groupBy(Iterable self, List<Closure> closures)
    Sorts all Iterable members into (sub)groups determined by the supplied mapping closures.
    static Map
    groupBy(Object[] self, Object... closures)
    Sorts all array members into (sub)groups determined by the supplied mapping closures as per the Iterable variant of this method.
    static Map
    groupBy(Object[] self, List<Closure> closures)
    Sorts all array members into (sub)groups determined by the supplied mapping closures as per the list variant of this method.
    static <G, K, V> Map<G,Map<K,V>>
    groupBy(Map<K,V> self, Closure<G> closure)
    Groups the members of a map into sub maps determined by the supplied mapping closure.
    static Map<Object,Map>
    groupBy(Map self, Object... closures)
    Groups the members of a map into sub maps determined by the supplied mapping closures.
    static Map<Object,Map>
    groupBy(Map self, List<Closure> closures)
    Groups the members of a map into sub maps determined by the supplied mapping closures.
    static <K, T> Map<K,List<T>>
    groupBy(T[] self, Closure<K> closure)
    Sorts all array members into groups determined by the supplied mapping closure.
    static <G, K, V> Map<G,List<Map.Entry<K,V>>>
    groupEntriesBy(Map<K,V> self, Closure<G> closure)
    Groups all map entries into groups determined by the supplied mapping closure.
    hasProperty(Object self, String name)
    Returns true of the implementing MetaClass has a property of the given name
    static <T> T
    head(Iterable<T> self)
    Returns the first item from the Iterable.
    static <T> T
    head(List<T> self)
    Returns the first item from the List.
    static <T> T
    head(T[] self)
    Returns the first item from the Object array.
    static <T, U> T
    identity(U self, Closure<T> closure)
    Allows the closure to be called for the object reference self.
    static Boolean
    implies(Boolean left, Boolean right)
    Logical implication of two boolean operators
    indexed(double[] self)
    Zips a double[] with indices in (index, value) order starting from index 0.
    indexed(double[] self, int offset)
    Zips a double[] with indices in (index, value) order.
    indexed(int[] self)
    Zips an int[] with indices in (index, value) order starting from index 0.
    indexed(int[] self, int offset)
    Zips an int[] with indices in (index, value) order.
    static Map<Integer,Long>
    indexed(long[] self)
    Zips a long[] with indices in (index, value) order starting from index 0.
    static Map<Integer,Long>
    indexed(long[] self, int offset)
    Zips a long[] with indices in (index, value) order.
    static <E> Map<Integer,E>
    indexed(Iterable<E> self)
    Zips an Iterable with indices in (index, value) order.
    static <E> Map<Integer,E>
    indexed(Iterable<E> self, int offset)
    Zips an Iterable with indices in (index, value) order.
    static <E> Iterator<Tuple2<Integer,E>>
    indexed(Iterator<E> self)
    Zips an iterator with indices in (index, value) order.
    static <E> Iterator<Tuple2<Integer,E>>
    indexed(Iterator<E> self, int offset)
    Zips an iterator with indices in (index, value) order.
    static <T> Collection<T>
    init(Iterable<T> self)
    Returns the items from the Iterable excluding the last item.
    static <T> Iterator<T>
    init(Iterator<T> self)
    Returns an Iterator containing all the items from this iterator except the last one.
    static <T> List<T>
    init(List<T> self)
    Returns the items from the List excluding the last item.
    static <T> SortedSet<T>
    init(SortedSet<T> self)
    Returns the items from the SortedSet excluding the last item.
    static <T> T[]
    init(T[] self)
    Returns the items from the Object array excluding the last item.
    static <T> List<List<T>>
    inits(Iterable<T> self)
    Calculates the init values of this Iterable: the first value will be this list of all items from the iterable and the final one will be an empty list, with the intervening values the results of successive applications of init on the items.
    static <E, T, V extends T>
    T
    inject(E[] self, Closure<V> closure)
    Iterates through the given array as with inject(Object[],initialValue,closure), but using the first element of the array as the initialValue, and then iterating the remaining elements of the array.
    static <E, T, U extends T, V extends T>
    T
    inject(E[] self, U initialValue, Closure<V> closure)
    Iterates through the given array, passing in the initial value to the closure along with the first item.
    static <T, V extends T>
    T
    inject(Object self, Closure<V> closure)
    Iterates through the given Object, passing in the first value to the closure along with the first item.
    static <T, U extends T, V extends T>
    T
    inject(Object self, U initialValue, Closure<V> closure)
    Iterates through the given Object, passing in the initial value to the closure along with the first item.
    static <E, T, U extends T, V extends T>
    T
    inject(Collection<E> self, U initialValue, Closure<V> closure)
    Iterates through the given Collection, passing in the initial value to the 2-arg closure along with the first item.
    static <T, V extends T>
    T
    inject(Collection<T> self, Closure<V> closure)
    Performs the same function as the version of inject that takes an initial value, but uses the head of the Collection as the initial value, and iterates over the tail.
    static <E, T, U extends T, V extends T>
    T
    inject(Iterator<E> self, U initialValue, Closure<V> closure)
    Iterates through the given Iterator, passing in the initial value to the closure along with the first item.
    static <K, V, T, U extends T, W extends T>
    T
    inject(Map<K,V> self, U initialValue, Closure<W> closure)
    Iterates through the given Map, passing in the initial value to the 2-arg Closure along with the first item (or 3-arg Closure along with the first key and value).
    static String
    Inspects returns the String that matches what would be typed into a terminal to create this object.
    static Number
    intdiv(Character left, Character right)
    Integer Divide two Characters.
    static Number
    intdiv(Character left, Number right)
    Integer Divide a Character by a Number.
    static Number
    intdiv(Number left, Character right)
    Integer Divide a Number by a Character.
    static Number
    intdiv(Number left, Number right)
    Integer Divide two Numbers.
    static <T> Collection<T>
    intersect(Iterable<T> left, Iterable<T> right)
    Create a Collection composed of the intersection of both iterables.
    static <T> Collection<T>
    intersect(Iterable<T> left, Iterable<T> right, Closure condition)
    Create a Collection composed of the intersection of both iterables.
    static <T> Collection<T>
    intersect(Iterable<T> left, Iterable<T> right, Comparator<? super T> comparator)
    Create a Collection composed of the intersection of both iterables.
    static <T> Collection<T>
    intersect(Collection<T> left, Collection<T> right)
    Create a Collection composed of the intersection of both collections.
    static <T> Collection<T>
    intersect(Collection<T> left, Collection<T> right, Comparator<? super T> comparator)
    Create a Collection composed of the intersection of both collections.
    static <T> List<T>
    intersect(List<T> left, Iterable<T> right)
    Create a List composed of the intersection of a List and an Iterable.
    static <T> List<T>
    intersect(List<T> left, Iterable<T> right, Comparator<? super T> comparator)
    Create a List composed of the intersection of a List and an Iterable.
    static <K, V> Map<K,V>
    intersect(Map<K,V> left, Map<K,V> right)
    Create a Map composed of the intersection of both maps.
    static <T> Set<T>
    intersect(Set<T> left, Iterable<T> right)
    Create a Set composed of the intersection of a Set and an Iterable.
    static <T> Set<T>
    intersect(Set<T> left, Iterable<T> right, Comparator<? super T> comparator)
    Create a Set composed of the intersection of a Set and an Iterable.
    static <T> SortedSet<T>
    intersect(SortedSet<T> left, Iterable<T> right)
    Create a SortedSet composed of the intersection of a SortedSet and an Iterable.
    static <T> SortedSet<T>
    intersect(SortedSet<T> left, Iterable<T> right, Comparator<? super T> comparator)
    Create a SortedSet composed of the intersection of a SortedSet and an Iterable.
    static Object
    invokeMethod(Object object, String method, Object arguments)
    Provide a dynamic method invocation method which can be overloaded in classes to implement dynamic proxies easily.
    static boolean
    is(Object self, Object other)
    Identity check.
    static Boolean
    isAtLeast(BigDecimal left, String right)
    Compare a BigDecimal to a String representing a number.
    static Boolean
    Compare a BigDecimal to another.
    static boolean
    isCase(Class caseValue, Object switchValue)
    Special 'Case' implementation for Class, which allows testing whether some switch value is assignable from the given case class.
    static boolean
    isCase(Number caseValue, Number switchValue)
    Special 'case' implementation for all numbers, which delegates to the compareTo() method for comparing numbers of different types.
    static boolean
    isCase(Object caseValue, Object switchValue)
    Method for overloading the behavior of the 'case' method in switch statements.
    static boolean
    isCase(Collection caseValue, Object switchValue)
    'Case' implementation for collections which tests if the 'switch' operand is contained in any of the 'case' values.
    static boolean
    isCase(Map caseValue, Object switchValue)
    'Case' implementation for maps which tests the groovy truth value obtained using the 'switch' operand as key.
    static boolean
    Determines if a character is a digit.
    static boolean
    Check whether an Iterable has elements
    static boolean
    Determines if a character is a letter.
    static boolean
    Determines if a character is a letter or digit.
    static boolean
    Determine if a Character is lowercase.
    static boolean
    isNotCase(Closure<?> caseValue, Object switchValue)
     
    static boolean
    isNotCase(Class<?> caseValue, Object switchValue)
     
    static boolean
    isNotCase(Number caseValue, Number switchValue)
     
    static boolean
    isNotCase(Object caseValue, Object switchValue)
     
    static boolean
    isNotCase(Collection<?> caseValue, Object switchValue)
     
    static boolean
    isNotCase(Map<?,?> caseValue, Object switchValue)
     
    static boolean
    Determine if a Character is uppercase.
    static boolean
    Determines if a character is a whitespace character.
    static Iterator
    Attempts to create an Iterator for the given object by first converting it to a Collection.
    static <T> Iterator<T>
    iterator(Enumeration<T> enumeration)
    Allows an Enumeration to behave like an Iterator.
    static <T> Iterator<T>
    iterator(Iterator<T> self)
    An identity function for iterators, supporting 'duck-typing' when trying to get an iterator for each object within a collection, some of which may already be iterators.
    static <T> Iterator<T>
    iterator(T[] a)
    Attempts to create an Iterator for the given object by first converting it to a Collection.
    static String
    join(boolean[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(byte[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(char[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(double[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(float[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(int[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(long[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(short[] self, String separator)
    Concatenates the string representation of each item in this array, with the given String as a separator between each item.
    static String
    join(Iterable<?> self, String separator)
    Concatenates the toString() representation of each item in this Iterable, with the given String as a separator between each item.
    static String
    join(Iterator<?> self, String separator)
    Concatenates the toString() representation of each item from the iterator, with the given String as a separator between each item.
    static <T> String
    join(T[] self, String separator)
    Concatenates the toString() representation of each item in this array, with the given String as a separator between each item.
    static <T> T
    last(Iterable<T> self)
    Returns the last item from the Iterable.
    static <T> T
    last(Deque<T> self)
    An optimized version of last(List).
    static <T> T
    last(List<T> self)
    Returns the last item from the List.
    static <T> T
    last(T[] self)
    Returns the last item from the array.
    static Number
    leftShift(Number self, Number operand)
    Implementation of the left shift operator for integral types.
    static <T> Collection<T>
    leftShift(Collection<T> self, T value)
    Overloads the left shift operator to provide an easy way to append objects to a Collection.
    static <T> BlockingQueue<T>
    leftShift(BlockingQueue<T> self, T value)
    Overloads the left shift operator to provide an easy way to append objects to a BlockingQueue.
    static <T> List<T>
    leftShift(List<T> self, T value)
    Overloads the left shift operator to provide an easy way to append objects to a List.
    static <K, V> Map<K,V>
    leftShift(Map<K,V> self, Map.Entry<K,V> entry)
    Overloads the left shift operator to provide an easy way to append Map.Entry values to a Map.
    static <K, V> Map<K,V>
    leftShift(Map<K,V> self, Map<K,V> other)
    Overloads the left shift operator to provide an easy way to put one maps entries into another map.
    static <T> Set<T>
    leftShift(Set<T> self, T value)
    Overloads the left shift operator to provide an easy way to append objects to a Set.
    static <T> SortedSet<T>
    leftShift(SortedSet<T> self, T value)
    Overloads the left shift operator to provide an easy way to append objects to a SortedSet.
    static double
    max(double[] self)
    Adds max() method to double arrays.
    static int
    max(int[] self)
    Adds max() method to int arrays.
    static long
    max(long[] self)
    Adds max() method to long arrays.
    static <T> T
    max(Iterable<T> self)
    Adds max() method to Iterable objects.
    static <T> T
    max(Iterable<T> self, Closure closure)
    Selects the item in the iterable which when passed as a parameter to the supplied closure returns the maximum value.
    static <T> T
    max(Iterable<T> self, Comparator<? super T> comparator)
    Selects the maximum value found in the Iterable using the given comparator.
    static <T> T
    max(Iterator<T> self)
    Adds max() method to Iterator objects.
    static <T> T
    max(Iterator<T> self, Closure closure)
    Selects the maximum value found from the Iterator using the closure to determine the correct ordering.
    static <T> T
    max(Iterator<T> self, Comparator<? super T> comparator)
    Selects the maximum value found from the Iterator using the given comparator.
    static <K, V> Map.Entry<K,V>
    max(Map<K,V> self, Closure closure)
    Selects an entry in the map having the maximum calculated value as determined by the supplied closure.
    static <T> T
    max(T[] self)
    Adds max() method to Object arrays.
    static <T> T
    max(T[] self, Closure closure)
    Selects the maximum value found from the Object array using the closure to determine the correct ordering.
    static <T> T
    max(T[] self, Comparator<? super T> comparator)
    Selects the maximum value found from the Object array using the given comparator.
    static MetaClass
    metaClass(Class self, Closure closure)
    Sets/updates the metaclass for a given class to a closure.
    static MetaClass
    metaClass(Object self, Closure closure)
    Sets/updates the metaclass for a given object to a closure.
    static double
    min(double[] self)
    Adds min() method to double arrays.
    static int
    min(int[] self)
    Adds min() method to int arrays.
    static long
    min(long[] self)
    Adds min() method to long arrays.
    static <T> T
    min(Iterable<T> self)
    Adds min() method to Collection objects.
    static <T> T
    min(Iterable<T> self, Closure closure)
    Selects the item in the iterable which when passed as a parameter to the supplied closure returns the minimum value.
    static <T> T
    min(Iterable<T> self, Comparator<? super T> comparator)
    Selects the minimum value found in the Iterable using the given comparator.
    static <T> T
    min(Iterator<T> self)
    Adds min() method to Iterator objects.
    static <T> T
    min(Iterator<T> self, Closure closure)
    Selects the minimum value found from the Iterator using the closure to determine the correct ordering.
    static <T> T
    min(Iterator<T> self, Comparator<? super T> comparator)
    Selects the minimum value found from the Iterator using the given comparator.
    static <K, V> Map.Entry<K,V>
    min(Map<K,V> self, Closure closure)
    Selects an entry in the map having the minimum calculated value as determined by the supplied closure.
    static <T> T
    min(T[] self)
    Adds min() method to Object arrays.
    static <T> T
    min(T[] self, Closure closure)
    Selects the minimum value found from the Object array using the closure to determine the correct ordering.
    static <T> T
    min(T[] self, Comparator<? super T> comparator)
    Selects the minimum value found from the Object array using the given comparator.
    static Number
    minus(Character left, Character right)
    Subtract one Character from another.
    static Number
    minus(Character left, Number right)
    Subtract a Number from a Character.
    static <T> Collection<T>
    minus(Iterable<T> self, Iterable<?> removeMe)
    Create a new Collection composed of the elements of the first Iterable minus every occurrence of elements of the given Iterable.
    static <T> Collection<T>
    minus(Iterable<T> self, Iterable<?> removeMe, Closure condition)
    Create a new Collection composed of the elements of the first Iterable minus every matching occurrence as determined by the condition closure of elements of the given Iterable.
    static <T> Collection<T>
    minus(Iterable<T> self, Iterable<?> removeMe, Comparator<? super T> comparator)
    Create a new Collection composed of the elements of the first Iterable minus every matching occurrence as determined by the condition comparator of elements of the given Iterable.
    static <T> Collection<T>
    minus(Iterable<T> self, Object removeMe)
    Create a new Collection composed of the elements of the first Iterable minus every occurrence of the given element to remove.
    static Number
    minus(Number left, Character right)
    Subtract a Character from a Number.
    static <T> Collection<T>
    minus(Collection<T> self, Collection<?> removeMe)
    Create a new Collection composed of the elements of the first Collection minus every occurrence of elements of the given Collection.
    static <T> List<T>
    minus(List<T> self, Iterable<?> removeMe)
    Create a new List composed of the elements of the first List minus every occurrence of elements of the given Iterable.
    static <T> List<T>
    minus(List<T> self, Object removeMe)
    Create a new List composed of the elements of the first List minus every occurrence of the given element to remove.
    static <T> List<T>
    minus(List<T> self, Collection<?> removeMe)
    Create a List composed of the elements of the first list minus every occurrence of elements of the given Collection.
    static <K, V> Map<K,V>
    minus(Map<K,V> self, Map removeMe)
    Create a Map composed of the entries of the first map minus the entries of the given map.
    static <T> Set<T>
    minus(Set<T> self, Iterable<?> removeMe)
    Create a Set composed of the elements of the first Set minus the elements from the given Iterable.
    static <T> Set<T>
    minus(Set<T> self, Object removeMe)
    Create a Set composed of the elements of the first Set minus the given element.
    static <T> Set<T>
    minus(Set<T> self, Collection<?> removeMe)
    Create a Set composed of the elements of the first Set minus the elements of the given Collection.
    static <T> SortedSet<T>
    minus(SortedSet<T> self, Iterable<?> removeMe)
    Create a SortedSet composed of the elements of the first SortedSet minus the elements of the given Iterable.
    static <T> SortedSet<T>
    minus(SortedSet<T> self, Object removeMe)
    Create a SortedSet composed of the elements of the first SortedSet minus the given element.
    static <T> SortedSet<T>
    minus(SortedSet<T> self, Collection<?> removeMe)
    Create a SortedSet composed of the elements of the first SortedSet minus the elements of the given Collection.
    static <T> T[]
    minus(T[] self, Iterable removeMe)
    Create a new array composed of the elements of the first array minus the elements of the given Iterable.
    static <T> T[]
    minus(T[] self, Object removeMe)
    Create a new array composed of the elements of the given array minus every occurrence the given object.
    static <T> T[]
    minus(T[] self, Object[] removeMe)
    Create a new array composed of the elements of the first array minus the elements of the given array.
    static void
    mixin(MetaClass self, Class categoryClass)
    Extend class globally with category methods.
    static void
    mixin(MetaClass self, Class[] categoryClass)
    Extend class globally with category methods.
    static void
    mixin(MetaClass self, List<Class> categoryClasses)
    Extend object with category methods.
    static void
    mixin(Class self, Class categoryClass)
    Extend class globally with category methods.
    static void
    mixin(Class self, Class[] categoryClass)
    Extend class globally with category methods.
    static void
    mixin(Class self, List<Class> categoryClasses)
    Extend class globally with category methods.
    static Number
    mod(Number left, Number right)
    Performs a division modulus operation.
    static Number
    Multiply two Characters.
    static Number
    multiply(Character left, Number right)
    Multiply a Character by a Number.
    static <T> Collection<T>
    multiply(Iterable<T> self, Number factor)
    Create a Collection composed of the elements of this Iterable, repeated a certain number of times.
    static Number
    multiply(Number left, Character right)
    Multiply a Number by a Character.
    static Number
    multiply(BigDecimal left, Double right)
    Multiply a BigDecimal and a Double.
    static Number
    Multiply a BigDecimal and a BigInteger.
    static <T> List<T>
    multiply(List<T> self, Number factor)
    Create a List composed of the elements of this Iterable, repeated a certain number of times.
    static <T> T
    Convenience method to dynamically create a new instance of this class.
    static <T> T
    newInstance(Class<T> c, Object[] args)
    Helper to construct a new instance from the given arguments.
    static Character
    Increment a Character by one.
    static Number
    next(Number self)
    Increment a Number by one.
    static int
    Provides a method that compares two comparables using Groovy's default number aware comparator.
    static Boolean
    or(Boolean left, Boolean right)
    Logical disjunction of two boolean operators
    static Number
    or(Number left, Number right)
    Bitwise OR together two numbers.
    static BitSet
    or(BitSet left, BitSet right)
    Bitwise OR together two BitSets.
    static <T> Set<List<T>>
    Finds all permutations of an iterable.
    static <T, V> List<V>
    permutations(Iterable<T> self, Closure<V> function)
    Finds all permutations of an iterable, applies a function to each permutation and collects the result into a list.
    static Number
    plus(Character left, Character right)
    Add one Character to another.
    static Number
    plus(Character left, Number right)
    Add a Character and a Number.
    static <T> Collection<T>
    plus(Iterable<T> left, Iterable<T> right)
    Create a Collection as a union of two iterables.
    static <T> Collection<T>
    plus(Iterable<T> left, T right)
    Create a collection as a union of an Iterable and an Object.
    static Number
    plus(Number left, Character right)
    Add a Number and a Character.
    static <T> Collection<T>
    plus(Collection<T> left, Iterable<T> right)
    Create a Collection as a union of a Collection and an Iterable.
    static <T> Collection<T>
    plus(Collection<T> left, Collection<T> right)
    Create a Collection as a union of two collections.
    static <T> Collection<T>
    plus(Collection<T> left, T right)
    Create a collection as a union of a Collection and an Object.
    static <T> List<T>
    plus(List<T> self, int index, Iterable<T> additions)
    Creates a new List by inserting all the elements in the given Iterable to the elements from this List at the specified index.
    static <T> List<T>
    plus(List<T> self, int index, List<T> additions)
    Creates a new List by inserting all the elements in the given additions List to the elements from the original List at the specified index.
    static <T> List<T>
    plus(List<T> self, int index, T[] items)
    Creates a new List by inserting all the elements in the specified array to the elements from the original List at the specified index.
    static <T> List<T>
    plus(List<T> left, Iterable<T> right)
    Create a List as a union of a List and an Iterable.
    static <T> List<T>
    plus(List<T> left, Collection<T> right)
    Create a List as a union of a List and a Collection.
    static <T> List<T>
    plus(List<T> left, T right)
    Create a List as a union of a List and an Object.
    static <K, V> Map<K,V>
    plus(Map<K,V> self, Collection<? extends Map.Entry<? extends K,? extends V>> entries)
    Returns a new Map containing all entries from self and entries, giving precedence to entries.
    static <K, V> Map<K,V>
    plus(Map<K,V> left, Map<K,V> right)
    Returns a new Map containing all entries from left and right, giving precedence to right.
    static String
    plus(Map left, GString right)
    Appends a GString to the literal of the Map instance.
    static String
    plus(Map left, String right)
    Appends a String to the literal of the Map instance.
    static <T> Set<T>
    plus(Set<T> left, Iterable<T> right)
    Create a Set as a union of a Set and an Iterable.
    static <T> Set<T>
    plus(Set<T> left, Collection<T> right)
    Create a Set as a union of a Set and a Collection.
    static <T> Set<T>
    plus(Set<T> left, T right)
    Create a Set as a union of a Set and an Object.
    static <T> SortedSet<T>
    plus(SortedSet<T> left, Iterable<T> right)
    Create a SortedSet as a union of a SortedSet and an Iterable.
    static <T> SortedSet<T>
    plus(SortedSet<T> left, Collection<T> right)
    Create a SortedSet as a union of a SortedSet and a Collection.
    static <T> SortedSet<T>
    plus(SortedSet<T> left, T right)
    Create a SortedSet as a union of a SortedSet and an Object.
    static <T> T[]
    plus(T[] left, Iterable<?> right)
    Create an array containing elements from an original array plus those from an Iterable.
    static <T> T[]
    plus(T[] left, Object right)
    Create an array containing elements from an original array plus an additional appended element.
    static <T> T[]
    plus(T[] left, Object[] right)
    Create an array as a union of two arrays.
    static <T> T[]
    plus(T[] left, Collection<?> right)
    Create an array containing elements from an original array plus those from a Collection.
    static <T> T
    pop(List<T> self)
    Removes the initial item from the List.
    static Number
    power(Integer self, Integer exponent)
    Power of an integer to an integer certain exponent.
    static Number
    power(Long self, Integer exponent)
    Power of a long to an integer certain exponent.
    static Number
    power(Number self, Number exponent)
    Power of a Number to a certain exponent.
    static Number
    power(BigDecimal self, Integer exponent)
    Power of a BigDecimal to an integer certain exponent.
    static Number
    power(BigInteger self, Integer exponent)
    Power of a BigInteger to an integer certain exponent.
    static BigInteger
    power(BigInteger self, BigInteger exponent)
    Power of a BigInteger to a BigInteger certain exponent.
    static Character
    Decrement a Character by one.
    static Number
    Decrement a Number by one.
    protected static Object
    primitiveArrayGet(Object self, int idx)
    Implements the getAt(int) method for primitive type arrays.
    protected static List
    Implements the getAt(Range) method for primitive type arrays.
    protected static List
    Implements the getAt(Collection) method for primitive type arrays.
    protected static Object
    primitiveArrayPut(Object self, int idx, Object newValue)
    Implements the setAt(int idx) method for primitive type arrays.
    static void
    print(Closure self, Object value)
    Print a value to the standard output stream.
    static void
    print(PrintStream self, Object value)
    Print a value formatted Groovy style to the print stream.
    static void
    print(PrintWriter self, Object value)
    Print a value formatted Groovy style to the print writer.
    static void
    print(Object self, PrintWriter out)
    Print to a console in interactive format.
    static void
    print(Object self, Object value)
    Print a value formatted Groovy style to self if it is a Writer, otherwise to the standard output stream.
    static void
    printf(Closure self, String format, Object value)
    Printf a value to the standard output stream using a format string.
    static void
    printf(Closure self, String format, Object[] values)
    Printf 0 or more values to the standard output stream using a format string.
    static void
    printf(Object self, String format, Object arg)
    Prints a formatted string using the specified format string and arguments.
    static void
    printf(Object self, String format, Object[] values)
    Printf to the standard output stream.
    static void
    Print a linebreak to the standard output stream.
    static void
    println(Closure self, Object value)
    Print a value (followed by a newline) to the standard output stream.
    static void
    println(PrintStream self, Object value)
    Print a value formatted Groovy style (followed by a newline) to the print stream.
    static void
    println(PrintWriter self, Object value)
    Print a value formatted Groovy style (followed by a newline) to the print writer.
    static void
    Print a linebreak to the standard output stream.
    static void
    Print to a console in interactive format.
    static void
    println(Object self, Object value)
    Print a value formatted Groovy style (followed by a newline) to self if it is a Writer, otherwise to the standard output stream.
    static <T> boolean
    push(List<T> self, T value)
    Prepends an item to the start of the List.
    static <K, V> Map<K,V>
    putAll(Map<K,V> self, Collection<? extends Map.Entry<? extends K,? extends V>> entries)
    Provides an easy way to append multiple Map.Entry values to a Map.
    static void
    putAt(Object self, String property, Object newValue)
    Allows the subscript operator to be used to set dynamically named property values.
    static void
    putAt(BitSet self, int index, boolean value)
    Support subscript-style assignment for a BitSet.
    static void
    putAt(BitSet self, IntRange range, boolean value)
    Support assigning a range of values with a single assignment statement.
    static <T> void
    putAt(List<T> self, int idx, T value)
    A helper method to allow lists to work with subscript operators.
    static <T> void
    putAt(List<T> self, Number idx, T value)
    Support subscript operator for list modification.
    static void
    putAt(List self, EmptyRange range, Object value)
    A helper method to allow lists to work with subscript operators.
    static void
    putAt(List self, EmptyRange range, Collection value)
    A helper method to allow lists to work with subscript operators.
    static void
    putAt(List self, IntRange range, Object value)
    List subscript assignment operator when given a range as the index.
    static void
    putAt(List self, IntRange range, Collection col)
    List subscript assignment operator when given a range as the index and the assignment operand is a collection.
    static void
    putAt(List self, List splice, Object value)
    A helper method to allow lists to work with subscript operators.
    static void
    putAt(List self, List splice, Collection values)
    A helper method to allow lists to work with subscript operators.
    static void
    putAt(List self, List splice, List values)
    Deprecated.
    use #putAt(List, List, Collection), retained for binary compatibility
    static <K, V> V
    putAt(Map<K,V> self, K key, V value)
    A helper method to allow maps to work with subscript operators
    static <T> boolean
    removeAll(Collection<T> self, Closure condition)
    Modifies this collection by removing the elements that are matched according to the specified closure condition.
    static boolean
    removeAll(Collection self, Object[] items)
    Modifies this collection by removing its elements that are contained within the specified object array.
    static <K, V> boolean
    removeAll(Map<K,V> self, Closure condition)
    Modifies this map by removing the elements that are matched according to the specified closure condition.
    static <E> E
    removeAt(List<E> self, int index)
    Modifies this list by removing the element at the specified position in this list.
    static <E> boolean
    Modifies this collection by removing a single instance of the specified element from this collection, if it is present.
    static <T> T
    removeLast(List<T> self)
    Removes the last item from the List.
    respondsTo(Object self, String name)
    Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of the arguments.
    respondsTo(Object self, String name, Object[] argTypes)
    Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.
    static <T> boolean
    retainAll(Collection<T> self, Closure condition)
    Modifies this collection so that it retains only its elements that are matched according to the specified closure condition.
    static boolean
    retainAll(Collection self, Object[] items)
    Modifies this collection so that it retains only its elements that are contained in the specified array.
    static <K, V> boolean
    retainAll(Map<K,V> self, Closure condition)
    Modifies this map so that it retains only its elements that are matched according to the specified closure condition.
    static <T> Iterator<T>
    reverse(Iterator<T> self)
    Reverses the iterator.
    static <T> List<T>
    reverse(List<T> self)
    Creates a new List with the identical contents to this list but in reverse order.
    static <T> List<T>
    reverse(List<T> self, boolean mutate)
    Reverses the elements in a list.
    static <T> T[]
    reverse(T[] self)
    Creates a new array containing items which are the same as this array but in reverse order.
    static <T> T[]
    reverse(T[] self, boolean mutate)
    Reverse the items in an array.
    static <T> List<T>
    reverseEach(List<T> self, Closure closure)
    Iterate over each element of the list in the reverse order.
    static <K, V> Map<K,V>
    reverseEach(Map<K,V> self, Closure<?> closure)
    Allows a Map to be iterated through in reverse order using a closure.
    static <T> NavigableSet<T>
    reverseEach(NavigableSet<T> self, Closure closure)
    Iterate over each element of the set in reverse order.
    static <T> T[]
    reverseEach(T[] self, Closure closure)
    Iterate over each element of the array in the reverse order.
    static Number
    rightShift(Number self, Number operand)
    Implementation of the right shift operator for integral types.
    static Number
    Implementation of the right shift (unsigned) operator for integral types.
    static long
    round(Double number)
    Round the value
    static double
    round(Double number, int precision)
    Round the value
    static int
    round(Float number)
    Round the value
    static float
    round(Float number, int precision)
    Round the value
    static BigDecimal
    round(BigDecimal number)
    Round the value
    static BigDecimal
    round(BigDecimal number, int precision)
    Round the value
    static TimerTask
    runAfter(Timer timer, int delay, Closure closure)
    Allows a simple syntax for using timers.
    static void
    Sets the metaclass for a GroovyObject.
    static void
    setMetaClass(Class self, MetaClass metaClass)
    Sets the metaclass for a given class.
    static void
    setMetaClass(Object self, MetaClass metaClass)
    Sets the metaclass for an object.
    static void
    shuffle(List<?> self)
    Randomly reorders the elements of the specified list.
    static void
    shuffle(List<?> self, Random rnd)
    Randomly reorders the elements of the specified list using the specified random instance as the source of randomness.
    static <T> void
    shuffle(T[] self)
    Randomly reorders the elements of the specified array.
    static <T> void
    shuffle(T[] self, Random rnd)
    Randomly reorders the elements of the specified array using the specified random instance as the source of randomness.
    static <T> List<T>
    shuffled(List<T> self)
    Creates a new list containing the elements of the specified list but in a random order.
    static <T> List<T>
    shuffled(List<T> self, Random rnd)
    Creates a new list containing the elements of the specified list but in a random order using the specified random instance as the source of randomness.
    static <T> T[]
    shuffled(T[] self)
    Creates a new array containing the elements of the specified array but in a random order.
    static <T> T[]
    shuffled(T[] self, Random rnd)
    Creates a new array containing the elements of the specified array but in a random order using the specified random instance as the source of randomness.
    static int
    size(boolean[] array)
    Allows arrays to behave similar to collections.
    static int
    size(byte[] array)
    Allows arrays to behave similar to collections.
    static int
    size(char[] array)
    Allows arrays to behave similar to collections.
    static int
    size(double[] array)
    Allows arrays to behave similar to collections.
    static int
    size(float[] array)
    Allows arrays to behave similar to collections.
    static int
    size(int[] array)
    Allows arrays to behave similar to collections.
    static int
    size(long[] array)
    Allows arrays to behave similar to collections.
    static int
    size(short[] array)
    Allows arrays to behave similar to collections.
    static int
    size(Iterable self)
    Provide the standard Groovy size() method for Iterable.
    static int
    size(Object[] self)
    Provide the standard Groovy size() method for an array.
    static int
    size(Iterator self)
    Provide the standard Groovy size() method for Iterator.
    static <T> List<T>
    sort(Iterable<T> self)
    Sorts the Collection.
    static <T> List<T>
    sort(Iterable<T> self, boolean mutate)
    Sorts the Iterable.
    static <T> List<T>
    sort(Iterable<T> self, boolean mutate, Closure closure)
    Sorts this Iterable using the given Closure to determine the correct ordering.
    static <T> List<T>
    sort(Iterable<T> self, boolean mutate, Comparator<? super T> comparator)
    Sorts the Iterable using the given Comparator.
    static <T> List<T>
    sort(Iterable<T> self, Closure closure)
    Sorts this Iterable using the given Closure to determine the correct ordering.
    static <T> Iterator<T>
    sort(Iterator<T> self)
    Sorts the given iterator items into a sorted iterator.
    static <T> Iterator<T>
    sort(Iterator<T> self, Closure closure)
    Sorts the given iterator items into a sorted iterator using the Closure to determine the correct ordering.
    static <T> Iterator<T>
    sort(Iterator<T> self, Comparator<? super T> comparator)
    Sorts the given iterator items into a sorted iterator using the comparator.
    static <K, V> Map<K,V>
    sort(Map<K,V> self)
    Sorts the elements from the given map into a new ordered Map using the natural ordering of the keys to determine the ordering.
    static <K, V> Map<K,V>
    sort(Map<K,V> self, Closure closure)
    Sorts the elements from the given map into a new ordered map using the closure as a comparator to determine the ordering.
    static <K, V> Map<K,V>
    sort(Map<K,V> self, Comparator<? super K> comparator)
    Sorts the elements from the given map into a new ordered Map using the specified key comparator to determine the ordering.
    static <K, V> SortedMap<K,V>
    sort(SortedMap<K,V> self)
    Avoids doing unnecessary work when sorting an already sorted map (i.e.
    static <T> SortedSet<T>
    sort(SortedSet<T> self)
    Avoids doing unnecessary work when sorting an already sorted set (i.e.
    static <T> T[]
    sort(T[] self)
    Modifies this array so that its elements are in sorted order.
    static <T> T[]
    sort(T[] self, boolean mutate)
    Sorts the given array into sorted order.
    static <T> T[]
    sort(T[] self, boolean mutate, Closure closure)
    Modifies this array so that its elements are in sorted order using the Closure to determine the correct ordering.
    static <T> T[]
    sort(T[] self, boolean mutate, Comparator<? super T> comparator)
    Modifies this array so that its elements are in sorted order as determined by the given comparator.
    static <T> T[]
    sort(T[] self, Closure closure)
    Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.
    static <T> T[]
    sort(T[] self, Comparator<? super T> comparator)
    Sorts the given array into sorted order using the given comparator.
    static Collection
    split(Object self, Closure closure)
    Splits all items into two lists based on the closure condition.
    static <T> Collection<Collection<T>>
    split(Collection<T> self, Closure closure)
    Splits all items into two collections based on the closure condition.
    static <T> List<List<T>>
    split(List<T> self, Closure closure)
    Splits all items into two collections based on the closure condition.
    static <T> List<Set<T>>
    split(Set<T> self, Closure closure)
    Splits all items into two collections based on the closure condition.
    static <T> Collection<Collection<T>>
    split(T[] self, Closure closure)
    Splits all items into two collections based on the closure condition.
    static SpreadMap
    spread(Map self)
    static String
    sprintf(Object self, String format, Object arg)
    Returns a formatted string using the specified format string and arguments.
    static String
    sprintf(Object self, String format, Object[] values)
    Sprintf to a string.
    static void
    step(Number self, Number to, Number stepNumber, Closure closure)
    Iterates from this number up to the given number using a step increment.
    static <K, V> Map<K,V>
    subMap(Map<K,V> map, Collection<K> keys)
    Creates a sub-Map containing the given keys.
    static <K, V> Map<K,V>
    subMap(Map<K,V> map, K[] keys)
    Creates a sub-Map containing the given keys.
    static <T> Set<List<T>>
    subsequences(List<T> self)
    Finds all non-null subsequences of a list.
    static byte
    sum(byte[] self)
    Sums the items in an array.
    static byte
    sum(byte[] self, byte initialValue)
    Sums the items in an array, adding the result to some initial value.
    static char
    sum(char[] self)
    Sums the items in an array.
    static char
    sum(char[] self, char initialValue)
    Sums the items in an array, adding the result to some initial value.
    static double
    sum(double[] self)
    Sums the items in an array.
    static double
    sum(double[] self, double initialValue)
    Sums the items in an array, adding the result to some initial value.
    static float
    sum(float[] self)
    Sums the items in an array.
    static float
    sum(float[] self, float initialValue)
    Sums the items in an array, adding the result to some initial value.
    static int
    sum(int[] self)
    Sums the items in an array.
    static int
    sum(int[] self, int initialValue)
    Sums the items in an array, adding the result to some initial value.
    static long
    sum(long[] self)
    Sums the items in an array.
    static long
    sum(long[] self, long initialValue)
    Sums the items in an array, adding the result to some initial value.
    static short
    sum(short[] self)
    Sums the items in an array.
    static short
    sum(short[] self, short initialValue)
    Sums the items in an array, adding the result to some initial value.
    static Object
    sum(Iterable<?> self)
    Sums the items in an Iterable.
    static Object
    sum(Iterable<?> self, Object initialValue)
    Sums the items in an Iterable, adding the result to some initial value.
    static <T> Object
    sum(Iterable<T> self, Closure closure)
    Sums the result of applying a closure to each item of an Iterable.
    static <T> Object
    sum(Iterable<T> self, Object initialValue, Closure closure)
    Sums the result of applying a closure to each item of an Iterable to some initial value.
    static Object
    sum(Object[] self)
    Sums the items in an array.
    static Object
    sum(Object[] self, Object initialValue)
    Sums the items in an array, adding the result to some initial value.
    static Object
    sum(Iterator<?> self, Object initialValue)
    Sums the items from an Iterator, adding the result to some initial value.
    static Object
    Sums the items from an Iterator.
    static <T> Object
    sum(Iterator<T> self, Closure closure)
    Sums the result of applying a closure to each item returned from an iterator.
    static <T> Object
    sum(Iterator<T> self, Object initialValue, Closure closure)
    Sums the result of applying a closure to each item of an Iterator to some initial value.
    static <T> Object
    sum(T[] self, Closure closure)
    Sums the result of applying a closure to each item of an array.
    static <T> Object
    sum(T[] self, Object initialValue, Closure closure)
    Sums the result of applying a closure to each item of an array to some initial value.
    static boolean[]
    swap(boolean[] self, int i, int j)
    Swaps two elements at the specified positions.
    static byte[]
    swap(byte[] self, int i, int j)
    Swaps two elements at the specified positions.
    static char[]
    swap(char[] self, int i, int j)
    Swaps two elements at the specified positions.
    static double[]
    swap(double[] self, int i, int j)
    Swaps two elements at the specified positions.
    static float[]
    swap(float[] self, int i, int j)
    Swaps two elements at the specified positions.
    static int[]
    swap(int[] self, int i, int j)
    Swaps two elements at the specified positions.
    static long[]
    swap(long[] self, int i, int j)
    Swaps two elements at the specified positions.
    static short[]
    swap(short[] self, int i, int j)
    Swaps two elements at the specified positions.
    static <T> List<T>
    swap(List<T> self, int i, int j)
    Swaps two elements at the specified positions.
    static <T> T[]
    swap(T[] self, int i, int j)
    Swaps two elements at the specified positions.
    static <T> Collection<T>
    tail(Iterable<T> self)
    Returns the items from the Iterable excluding the first item.
    static <T> Iterator<T>
    tail(Iterator<T> self)
    Returns the original iterator after throwing away the first element.
    static <T> List<T>
    tail(List<T> self)
    Returns the items from the List excluding the first item.
    static <T> SortedSet<T>
    tail(SortedSet<T> self)
    Returns the items from the SortedSet excluding the first item.
    static <T> T[]
    tail(T[] self)
    Returns the items from the array excluding the first item.
    static <T> List<List<T>>
    tails(Iterable<T> self)
    Calculates the tail values of this Iterable: the first value will be this list of all items from the iterable and the final one will be an empty list, with the intervening values the results of successive applications of tail on the items.
    static <T> Collection<T>
    take(Iterable<T> self, int num)
    Returns the first num elements from the head of this Iterable.
    static <T> Iterator<T>
    take(Iterator<T> self, int num)
    Returns an iterator of up to the first num elements from this iterator.
    static <T> List<T>
    take(List<T> self, int num)
    Returns the first num elements from the head of this List.
    static <K, V> Map<K,V>
    take(Map<K,V> self, int num)
    Returns a new map containing the first num elements from the head of this map.
    static <T> SortedSet<T>
    take(SortedSet<T> self, int num)
    Returns the first num elements from the head of this SortedSet.
    static <T> T[]
    take(T[] self, int num)
    Returns the first num elements from the head of this array.
    static <T> Collection<T>
    takeRight(Iterable<T> self, int num)
    Returns the last num elements from the tail of this Iterable.
    static <T> List<T>
    takeRight(List<T> self, int num)
    Returns the last num elements from the tail of this List.
    static <T> SortedSet<T>
    takeRight(SortedSet<T> self, int num)
    Returns the last num elements from the tail of this SortedSet.
    static <T> T[]
    takeRight(T[] self, int num)
    Returns the last num elements from the tail of this array.
    static <T> Collection<T>
    takeWhile(Iterable<T> self, Closure condition)
    Returns a Collection containing the longest prefix of the elements from this Iterable where each element passed to the given closure evaluates to true.
    static <T> Iterator<T>
    takeWhile(Iterator<T> self, Closure condition)
    Returns the longest prefix of elements in this iterator where each element passed to the given condition closure evaluates to true.
    static <T> List<T>
    takeWhile(List<T> self, Closure condition)
    Returns the longest prefix of this list where each element passed to the given closure condition evaluates to true.
    static <K, V> Map<K,V>
    takeWhile(Map<K,V> self, Closure condition)
    Returns the longest prefix of this Map where each entry (or key/value pair) when passed to the given closure evaluates to true.
    static <T> SortedSet<T>
    takeWhile(SortedSet<T> self, Closure condition)
    Returns the longest prefix of this SortedSet where each element passed to the given closure condition evaluates to true.
    static <T> T[]
    takeWhile(T[] self, Closure condition)
    Returns the longest prefix of this array where each element passed to the given closure evaluates to true.
    static <T, U> U
    tap(U self, Closure<T> closure)
    Allows the closure to be called for the object reference self (similar to with) and always returns self.
    static void
    times(Number self, Closure closure)
    Executes the closure this many times, starting from zero.
    static String
    Returns the string representation of the given array.
    static BigDecimal
    Transform a Number into a BigDecimal
    static BigInteger
    Transform this Number into a BigInteger.
    static Boolean
    Identity conversion which returns Boolean.TRUE for a true Boolean and Boolean.FALSE for a false Boolean.
    static Double
    Transform a Number into a Double
    static Float
    Transform a Number into a Float
    static Integer
    Transform a Number into an Integer
    static List<Boolean>
    toList(boolean[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Byte>
    toList(byte[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Character>
    toList(char[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Double>
    toList(double[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Float>
    toList(float[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Integer>
    toList(int[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Long>
    toList(long[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static List<Short>
    toList(short[] array)
    Converts this array to a List of the same size, with each element added to the list.
    static <T> List<T>
    toList(Iterable<T> self)
    Convert an Iterable to a List.
    static <T> List<T>
    Convert an enumeration to a List.
    static <T> List<T>
    toList(Iterator<T> self)
    Convert an iterator to a List.
    static <T> List<T>
    toList(T[] array)
    Allows conversion of arrays into a mutable List.
    static String
    Returns the string representation of the given list.
    static String
    toListString(Collection self, int maxSize)
    Returns the string representation of the given list.
    static Long
    toLong(Number self)
    Transform a Number into a Long
    static char
    Converts the character to lowercase.
    static String
    Returns the string representation of this map.
    static String
    toMapString(Map self, int maxSize)
    Returns the string representation of this map.
    static Set<Boolean>
    toSet(boolean[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Byte>
    toSet(byte[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Character>
    toSet(char[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Double>
    toSet(double[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Float>
    toSet(float[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Integer>
    toSet(int[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Long>
    toSet(long[] array)
    Converts this array to a Set, with each unique element added to the set.
    static Set<Short>
    toSet(short[] array)
    Converts this array to a Set, with each unique element added to the set.
    static <T> Set<T>
    toSet(Iterable<T> self)
    Convert an Iterable to a Set.
    static <T> Set<T>
    toSet(Collection<T> self)
    Convert a Collection to a Set.
    static <T> Set<T>
    toSet(Enumeration<T> self)
    Convert an enumeration to a Set.
    static <T> Set<T>
    toSet(Iterator<T> self)
    Convert an iterator to a Set.
    static <T> List<T>
    toSorted(Iterable<T> self)
    Sorts the Iterable.
    static <T> List<T>
    toSorted(Iterable<T> self, Closure closure)
    Sorts this Iterable using the given Closure to determine the correct ordering.
    static <T> List<T>
    toSorted(Iterable<T> self, Comparator<? super T> comparator)
    Sorts the Iterable using the given Comparator.
    static <T> Iterator<T>
    toSorted(Iterator<T> self)
    Sorts the Iterator.
    static <T> Iterator<T>
    toSorted(Iterator<T> self, Closure closure)
    Sorts the given iterator items into a sorted iterator using the Closure to determine the correct ordering.
    static <T> Iterator<T>
    toSorted(Iterator<T> self, Comparator<? super T> comparator)
    Sorts the given iterator items using the comparator.
    static <K, V> Map<K,V>
    toSorted(Map<K,V> self)
    Sorts the elements from the given map into a new ordered map using a NumberAwareComparator on map entry values to determine the resulting order.
    static <K, V> Map<K,V>
    toSorted(Map<K,V> self, Closure condition)
    Sorts the elements from the given map into a new ordered map using the supplied Closure condition as a comparator to determine the ordering.
    static <K, V> Map<K,V>
    toSorted(Map<K,V> self, Comparator<Map.Entry<K,V>> comparator)
    Sorts the elements from the given map into a new ordered map using the supplied comparator to determine the ordering.
    static <K, V> Map<K,V>
    toSorted(SortedMap<K,V> self)
    Avoids doing unnecessary work when sorting an already sorted map
    static <T> Set<T>
    Avoids doing unnecessary work when sorting an already sorted set
    static <T> T[]
    toSorted(T[] self)
    Returns a sorted version of the given array using the supplied comparator.
    static <T> T[]
    toSorted(T[] self, Closure closure)
    Sorts the elements from this array into a newly created array using the Closure to determine the correct ordering.
    static <T> T[]
    toSorted(T[] self, Comparator<? super T> comparator)
    Returns a sorted version of the given array using the supplied comparator to determine the resulting order.
    static SpreadMap
    Creates a spreadable map from this iterable.
    static SpreadMap
    Creates a spreadable map from this array.
    static SpreadMap
    Creates a spreadable map from this list.
    static SpreadMap
    Returns a new SpreadMap from this map.
    static String
    toString(boolean[] self)
    Returns the string representation of the given array.
    static String
    toString(byte[] self)
    Returns the string representation of the given array.
    static String
    toString(char[] self)
    Returns the string representation of the given array.
    static String
    toString(double[] self)
    Returns the string representation of the given array.
    static String
    toString(float[] self)
    Returns the string representation of the given array.
    static String
    toString(int[] self)
    Returns the string representation of the given array.
    static String
    toString(long[] self)
    Returns the string representation of the given array.
    static String
    toString(short[] self)
    Returns the string representation of the given array.
    static String
    Create a String representation of this object.
    static String
    toString(Object[] self)
    Returns the string representation of this array's contents.
    static String
    Returns the string representation of the given collection.
    static String
    Returns the string representation of the given map.
    static <T> Collection<T>
    toUnique(Iterable<T> self)
    Returns a Collection containing the items from the Iterable but with duplicates removed using the natural ordering of the items to determine uniqueness.
    static <T> Collection<T>
    toUnique(Iterable<T> self, Closure condition)
    Returns a Collection containing the items from the Iterable but with duplicates removed.
    static <T> Collection<T>
    toUnique(Iterable<T> self, Comparator<? super T> comparator)
    Returns a Collection containing the items from the Iterable but with duplicates removed.
    static <T> Iterator<T>
    toUnique(Iterator<T> self)
    Returns an iterator equivalent to this iterator with all duplicated items removed by using the natural ordering of the items.
    static <T> Iterator<T>
    toUnique(Iterator<T> self, Closure condition)
    Returns an iterator equivalent to this iterator but with all duplicated items removed where duplicate (equal) items are deduced by calling the supplied Closure condition.
    static <T> Iterator<T>
    toUnique(Iterator<T> self, Comparator<? super T> comparator)
    Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator.
    static <T> List<T>
    toUnique(List<T> self)
    Returns a List containing the items from the List but with duplicates removed using the natural ordering of the items to determine uniqueness.
    static <T> List<T>
    toUnique(List<T> self, Closure condition)
    Returns a List containing the items from the List but with duplicates removed.
    static <T> List<T>
    toUnique(List<T> self, Comparator<? super T> comparator)
    Returns a List containing the items from the List but with duplicates removed.
    static <T> T[]
    toUnique(T[] self)
    Returns a new Array containing the items from the original Array but with duplicates removed using the natural ordering of the items in the array.
    static <T> T[]
    toUnique(T[] self, Closure condition)
    Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.
    static <T> T[]
    toUnique(T[] self, Comparator<? super T> comparator)
    Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.
    static char
    Converts the character to uppercase.
    static double[][]
    transpose(double[][] self)
    A transpose method for 2D double arrays.
    static int[][]
    transpose(int[][] self)
    A transpose method for 2D int arrays.
    static long[][]
    transpose(long[][] self)
    A transpose method for 2D long arrays.
    static List
    Adds GroovyCollections#transpose(List) as a method on lists.
    static double
    trunc(Double number)
    Truncate the value
    static double
    trunc(Double number, int precision)
    Truncate the value
    static float
    trunc(Float number)
    Truncate the value
    static float
    trunc(Float number, int precision)
    Truncate the value
    static BigDecimal
    trunc(BigDecimal number)
    Truncate the value
    static BigDecimal
    trunc(BigDecimal number, int precision)
    Truncate the value
    static Number
    Negates the number.
    static Number
    Returns the number, effectively being a noop for numbers.
    static Object[]
    union(Object[] left, Iterable<?> right)
    Create an Object array containing elements from an original array plus those from an Iterable.
    static Object[]
    union(Object[] left, Object right)
    Create an Object array containing elements from an original array plus an additional appended element.
    static Object[]
    union(Object[] left, Object[] right)
    Create an Object array as a union of two arrays.
    static Object[]
    union(Object[] left, Collection<?> right)
    Create an object array containing elements from an original array plus those from a Collection.
    static <T> Collection<T>
    unique(Collection<T> self)
    Modifies this collection to remove all duplicated items, using Groovy's default number-aware comparator.
    static <T> Collection<T>
    unique(Collection<T> self, boolean mutate)
    Remove all duplicates from a given Collection using Groovy's default number-aware comparator.
    static <T> Collection<T>
    unique(Collection<T> self, boolean mutate, Closure closure)
    A convenience method for making a collection unique using a Closure to determine duplicate (equal) items.
    static <T> Collection<T>
    unique(Collection<T> self, boolean mutate, Comparator<? super T> comparator)
    Remove all duplicates from a given Collection.
    static <T> Collection<T>
    unique(Collection<T> self, Closure closure)
    A convenience method for making a collection unique using a Closure to determine duplicate (equal) items.
    static <T> Collection<T>
    unique(Collection<T> self, Comparator<? super T> comparator)
    Remove all duplicates from a given Collection.
    static <T> Iterator<T>
    unique(Iterator<T> self)
    Returns an iterator equivalent to this iterator with all duplicated items removed by using Groovy's default number-aware comparator.
    static <T> Iterator<T>
    unique(Iterator<T> self, Closure condition)
    Returns an iterator equivalent to this iterator but with all duplicated items removed by using a Closure to determine duplicate (equal) items.
    static <T> Iterator<T>
    unique(Iterator<T> self, Comparator<? super T> comparator)
    Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator.
    static <T> List<T>
    unique(List<T> self)
    Modifies this List to remove all duplicated items, using Groovy's default number-aware comparator.
    static <T> List<T>
    unique(List<T> self, boolean mutate)
    Remove all duplicates from a given List using Groovy's default number-aware comparator.
    static <T> List<T>
    unique(List<T> self, boolean mutate, Closure closure)
    A convenience method for making a List unique using a Closure to determine duplicate (equal) items.
    static <T> List<T>
    unique(List<T> self, boolean mutate, Comparator<? super T> comparator)
    Remove all duplicates from a given List.
    static <T> List<T>
    unique(List<T> self, Closure closure)
    A convenience method for making a List unique using a Closure to determine duplicate (equal) items.
    static <T> List<T>
    unique(List<T> self, Comparator<? super T> comparator)
    Remove all duplicates from a given List.
    static void
    upto(double self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(float self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(long self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(Double self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(Float self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(Long self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(Number self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(BigDecimal self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static void
    upto(BigInteger self, Number to, Closure closure)
    Iterates from this number up to the given number, inclusive, incrementing by one each time.
    static <T> T
    use(Object self, Class categoryClass, Closure<T> closure)
    Scoped use method
    static Object
    use(Object self, Object[] array)
    Allows you to use a list of categories, specifying the list as varargs.
    static <T> T
    use(Object self, List<Class> categoryClassList, Closure<T> closure)
    Scoped use method with list of categories.
    static <T, U extends T, V extends T>
    T
    with(U self, boolean returning, Closure<T> closure)
    Allows the closure to be called for the object reference self.
    static <T, U> T
    with(U self, Closure<T> closure)
    Allows the closure to be called for the object reference self.
    static <T> ListWithDefault<T>
    withDefault(List<T> self, Closure<T> init)
    An alias for withLazyDefault which decorates a list allowing it to grow when called with index values outside the normal list bounds.
    static <K, V> Map<K,V>
    withDefault(Map<K,V> self, boolean autoGrow, boolean autoShrink, Closure<V> init)
    Wraps a map using the decorator pattern with a wrapper that intercepts all calls to get(key) and put(key, value).
    static <K, V> Map<K,V>
    withDefault(Map<K,V> self, Closure<V> init)
    Wraps a map using the decorator pattern with a wrapper that intercepts all calls to get(key).
    static <T> List<T>
    withDefault$$bridge(List<T> self, Closure<T> init)
    Deprecated.
    static <T> ListWithDefault<T>
    withEagerDefault(List<T> self, Closure<T> init)
    Decorates a list allowing it to grow when called with a non-existent index value.
    static <T> List<T>
    Deprecated.
    static <E> List<Tuple2<E,Integer>>
    Zips an Iterable with indices in (value, index) order.
    static <E> List<Tuple2<E,Integer>>
    withIndex(Iterable<E> self, int offset)
    Zips an Iterable with indices in (value, index) order.
    static <E> Iterator<Tuple2<E,Integer>>
    Zips an iterator with indices in (value, index) order.
    static <E> Iterator<Tuple2<E,Integer>>
    withIndex(Iterator<E> self, int offset)
    Zips an iterator with indices in (value, index) order.
    static <T> ListWithDefault<T>
    withLazyDefault(List<T> self, Closure<T> init)
    Decorates a list allowing it to grow when called with a non-existent index value.
    static <T> List<T>
    Deprecated.
    static Object
    withTraits(Object self, Class<?>... traits)
    Dynamically wraps an instance into something which implements the supplied trait classes.
    static Boolean
    xor(Boolean left, Boolean right)
    Exclusive disjunction of two boolean operators
    static Number
    xor(Number left, Number right)
    Bitwise XOR together two Numbers.
    static BitSet
    xor(BitSet left, BitSet right)
    Bitwise XOR together two BitSets.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ADDITIONAL_CLASSES

      public static final Class[] ADDITIONAL_CLASSES
    • DGM_LIKE_CLASSES

      public static final Class[] DGM_LIKE_CLASSES
  • Constructor Details

    • DefaultGroovyMethods

      public DefaultGroovyMethods()
  • Method Details

    • is

      public static boolean is(Object self, Object other)
      Identity check. Since == is overridden in Groovy with the meaning of equality we need some fallback to check for object identity. Invoke using the 'is' method, like so: def same = this.is(that)
      Parameters:
      self - an object
      other - an object to compare identity with
      Returns:
      true if self and other are both references to the same instance, false otherwise
      Since:
      1.0
    • identity

      public static <T, U> T identity(U self, @DelegatesTo(value=Target.class,target="self",strategy=1) Closure<T> closure)
      Allows the closure to be called for the object reference self. Synonym for 'with()'.
      Parameters:
      self - the object to have a closure act upon
      closure - the closure to call on the object
      Returns:
      result of calling the closure
      Since:
      1.0
      See Also:
    • with

      public static <T, U> T with(U self, @DelegatesTo(value=Target.class,target="self",strategy=1) Closure<T> closure)
      Allows the closure to be called for the object reference self.

      Any method invoked inside the closure will first be invoked on the self reference. For instance, the following method calls to the append() method are invoked on the StringBuilder instance:

       def b = new StringBuilder().with {
         append('foo')
         append('bar')
         return it
       }
       assert b.toString() == 'foobar'
       
      This is commonly used to simplify object creation, such as this example:
       def p = new Person().with {
         firstName = 'John'
         lastName = 'Doe'
         return it
       }
       
      The other typical usage, uses the self object while creating some value:
       def fullName = person.with{ "$firstName $lastName" }
       
      Parameters:
      self - the object to have a closure act upon
      closure - the closure to call on the object
      Returns:
      result of calling the closure
      Since:
      1.5.0
      See Also:
    • with

      public static <T, U extends T, V extends T> T with(U self, boolean returning, @DelegatesTo(value=Target.class,target="self",strategy=1) Closure<T> closure)
      Allows the closure to be called for the object reference self.

      Any method invoked inside the closure will first be invoked on the self reference. For example, the following method calls to the append() method are invoked on the StringBuilder instance and then, because 'returning' is true, the self instance is returned:

       def b = new StringBuilder().with(true) {
         append('foo')
         append('bar')
       }
       assert b.toString() == 'foobar'
       
      The returning parameter is commonly set to true when using with to simplify object creation, such as this example:
       def p = new Person().with(true) {
         firstName = 'John'
         lastName = 'Doe'
       }
       
      Alternatively, 'tap' is an alias for 'with(true)', so that method can be used instead. The other main use case for with is when returning a value calculated using self as shown here:
       def fullName = person.with(false){ "$firstName $lastName" }
       
      Alternatively, 'with' is an alias for 'with(false)', so the boolean parameter can be omitted instead.
      Parameters:
      self - the object to have a closure act upon
      returning - if true, return the self object; otherwise, the result of calling the closure
      closure - the closure to call on the object
      Returns:
      the self object or the result of calling the closure depending on 'returning'
      Since:
      2.5.0
      See Also:
    • tap

      public static <T, U> U tap(U self, @DelegatesTo(value=Target.class,target="self",strategy=1) Closure<T> closure)
      Allows the closure to be called for the object reference self (similar to with) and always returns self.

      Any method invoked inside the closure will first be invoked on the self reference. For instance, the following method calls to the append() method are invoked on the StringBuilder instance:

       def b = new StringBuilder().tap {
         append('foo')
         append('bar')
       }
       assert b.toString() == 'foobar'
       
      This is commonly used to simplify object creation, such as this example:
       def p = new Person().tap {
         firstName = 'John'
         lastName = 'Doe'
       }
       
      Parameters:
      self - the object to have a closure act upon
      closure - the closure to call on the object
      Returns:
      self
      Since:
      2.5.0
      See Also:
    • getAt

      public static Object getAt(Object self, String property)
      Allows the subscript operator to be used to lookup dynamic property values. bean[somePropertyNameExpression]. The normal property notation of groovy is neater and more concise but only works with compile-time known property names.
      Parameters:
      self - the object to act upon
      property - the property name of interest
      Returns:
      the property value
      Since:
      1.0
    • putAt

      public static void putAt(Object self, String property, Object newValue)
      Allows the subscript operator to be used to set dynamically named property values. bean[somePropertyNameExpression] = foo. The normal property notation of groovy is neater and more concise but only works with property names which are known at compile time.
      Parameters:
      self - the object to act upon
      property - the name of the property to set
      newValue - the value to set
      Since:
      1.0
    • dump

      public static String dump(Object self)
      Generates a detailed dump string of an object showing its class, hashCode and all accessible fields.
      Parameters:
      self - an object
      Returns:
      the dump representation
      Since:
      1.0
    • getMetaPropertyValues

      public static List<PropertyValue> getMetaPropertyValues(Object self)
      Retrieves the list of MetaProperty objects for 'self' and wraps it in a list of PropertyValue objects that additionally provide the value for each property of 'self'.
      Parameters:
      self - the receiver object
      Returns:
      list of PropertyValue objects
      Since:
      1.0
      See Also:
    • getProperties

      public static Map getProperties(Object self)
      Convenience method that calls getMetaPropertyValues(java.lang.Object)(self) and provides the data in form of simple key/value pairs, i.e. without type() information.
      Parameters:
      self - the receiver object
      Returns:
      meta properties as Map of key/value pairs
      Since:
      1.0
    • use

      public static <T> T use(Object self, Class categoryClass, Closure<T> closure)
      Scoped use method
      Parameters:
      self - any Object
      categoryClass - a category class to use
      closure - the closure to invoke with the category in place
      Returns:
      the value returned from the closure
      Since:
      1.0
    • mixin

      public static void mixin(MetaClass self, List<Class> categoryClasses)
      Extend object with category methods. All methods for given class and all super classes will be added to the object.
      Parameters:
      self - any Class
      categoryClasses - a category classes to use
      Since:
      1.6.0
    • mixin

      public static void mixin(Class self, List<Class> categoryClasses)
      Extend class globally with category methods. All methods for given class and all super classes will be added to the class.
      Parameters:
      self - any Class
      categoryClasses - a category classes to use
      Since:
      1.6.0
    • mixin

      public static void mixin(Class self, Class categoryClass)
      Extend class globally with category methods.
      Parameters:
      self - any Class
      categoryClass - a category class to use
      Since:
      1.6.0
    • mixin

      public static void mixin(Class self, Class[] categoryClass)
      Extend class globally with category methods.
      Parameters:
      self - any Class
      categoryClass - a category class to use
      Since:
      1.6.0
    • mixin

      public static void mixin(MetaClass self, Class categoryClass)
      Extend class globally with category methods.
      Parameters:
      self - any Class
      categoryClass - a category class to use
      Since:
      1.6.0
    • mixin

      public static void mixin(MetaClass self, Class[] categoryClass)
      Extend class globally with category methods.
      Parameters:
      self - any Class
      categoryClass - a category class to use
      Since:
      1.6.0
    • getLocation

      public static URL getLocation(Class self)
      Gets the url of the jar file/source file containing the specified class
      Parameters:
      self - the class
      Returns:
      the url of the jar, null if the specified class is from JDK
      Since:
      2.5.0
    • addShutdownHook

      public static void addShutdownHook(Object self, Closure closure)
      Allows the usage of addShutdownHook without getting the runtime first.
      Parameters:
      self - the object the method is called on (ignored)
      closure - the shutdown hook action
      Since:
      1.5.0
    • use

      public static <T> T use(Object self, List<Class> categoryClassList, Closure<T> closure)
      Scoped use method with list of categories.
      Parameters:
      self - any Object
      categoryClassList - a list of category classes
      closure - the closure to invoke with the categories in place
      Returns:
      the value returned from the closure
      Since:
      1.0
    • use

      public static Object use(Object self, Object[] array)
      Allows you to use a list of categories, specifying the list as varargs. use(CategoryClass1, CategoryClass2) { ... } This method saves having to wrap the category classes in a list.
      Parameters:
      self - any Object
      array - a list of category classes and a Closure
      Returns:
      the value returned from the closure
      Since:
      1.0
    • inspect

      public static String inspect(Object self)
      Inspects returns the String that matches what would be typed into a terminal to create this object.
      Parameters:
      self - any Object
      Returns:
      a String that matches what would be typed into a terminal to create this object. e.g. [1, 'hello'].inspect() -> [1, 'hello']
      Since:
      1.0
    • invokeMethod

      public static Object invokeMethod(Object object, String method, Object arguments)
      Provide a dynamic method invocation method which can be overloaded in classes to implement dynamic proxies easily.
      Parameters:
      object - any Object
      method - the name of the method to call
      arguments - the arguments to use
      Returns:
      the result of the method call
      Since:
      1.0
    • print

      public static void print(Object self, Object value)
      Print a value formatted Groovy style to self if it is a Writer, otherwise to the standard output stream.
      Parameters:
      self - any Object
      value - the value to print
      Since:
      1.0
    • print

      public static void print(PrintWriter self, Object value)
      Print a value formatted Groovy style to the print writer.
      Parameters:
      self - a PrintWriter
      value - the value to print
      Since:
      1.0
    • print

      public static void print(PrintStream self, Object value)
      Print a value formatted Groovy style to the print stream.
      Parameters:
      self - a PrintStream
      value - the value to print
      Since:
      1.6.0
    • print

      public static void print(Closure self, Object value)
      Print a value to the standard output stream. This method delegates to the owner to execute the method.
      Parameters:
      self - a generated closure
      value - the value to print
      Since:
      1.0
    • print

      public static void print(Object self, PrintWriter out)
      Print to a console in interactive format.
      Parameters:
      self - any Object
      out - the PrintWriter used for printing
      Since:
      1.0
    • println

      public static void println(Object self)
      Print a linebreak to the standard output stream.
      Parameters:
      self - any Object
      Since:
      1.0
    • println

      public static void println(Closure self)
      Print a linebreak to the standard output stream. This method delegates to the owner to execute the method.
      Parameters:
      self - a closure
      Since:
      1.0
    • println

      public static void println(Object self, Object value)
      Print a value formatted Groovy style (followed by a newline) to self if it is a Writer, otherwise to the standard output stream.
      Parameters:
      self - any Object
      value - the value to print
      Since:
      1.0
    • println

      public static void println(PrintWriter self, Object value)
      Print a value formatted Groovy style (followed by a newline) to the print writer.
      Parameters:
      self - a PrintWriter
      value - the value to print
      Since:
      1.0
    • println

      public static void println(PrintStream self, Object value)
      Print a value formatted Groovy style (followed by a newline) to the print stream.
      Parameters:
      self - any Object
      value - the value to print
      Since:
      1.6.0
    • println

      public static void println(Closure self, Object value)
      Print a value (followed by a newline) to the standard output stream. This method delegates to the owner to execute the method.
      Parameters:
      self - a closure
      value - the value to print
      Since:
      1.0
    • println

      public static void println(Object self, PrintWriter out)
      Print to a console in interactive format.
      Parameters:
      self - any Object
      out - the PrintWriter used for printing
      Since:
      1.0
    • printf

      public static void printf(Object self, String format, Object[] values)
      Printf to the standard output stream.
      Parameters:
      self - any Object
      format - a format string
      values - values referenced by the format specifiers in the format string
      Since:
      1.0
    • printf

      public static void printf(Closure self, String format, Object[] values)
      Printf 0 or more values to the standard output stream using a format string. This method delegates to the owner to execute the method.
      Parameters:
      self - a generated closure
      format - a format string
      values - values referenced by the format specifiers in the format string
      Since:
      3.0.0
    • printf

      public static void printf(Closure self, String format, Object value)
      Printf a value to the standard output stream using a format string. This method delegates to the owner to execute the method.
      Parameters:
      self - a generated closure
      format - a format string
      value - value referenced by the format specifier in the format string
      Since:
      3.0.0
    • printf

      public static void printf(Object self, String format, Object arg)
      Prints a formatted string using the specified format string and arguments.

      Examples:

           printf ( "Hello, %s!\n" , [ "world" ] as String[] )
           printf ( "Hello, %s!\n" , [ "Groovy" ])
           printf ( "%d + %d = %d\n" , [ 1 , 2 , 1+2 ] as Integer[] )
           printf ( "%d + %d = %d\n" , [ 3 , 3 , 3+3 ])
      
           ( 1..5 ).each { printf ( "-- %d\n" , [ it ] as Integer[] ) }
           ( 1..5 ).each { printf ( "-- %d\n" , [ it ] as int[] ) }
           ( 0x41..0x45 ).each { printf ( "-- %c\n" , [ it ] as char[] ) }
           ( 07..011 ).each { printf ( "-- %d\n" , [ it ] as byte[] ) }
           ( 7..11 ).each { printf ( "-- %d\n" , [ it ] as short[] ) }
           ( 7..11 ).each { printf ( "-- %d\n" , [ it ] as long[] ) }
           ( 7..11 ).each { printf ( "-- %5.2f\n" , [ it ] as float[] ) }
           ( 7..11 ).each { printf ( "-- %5.2g\n" , [ it ] as double[] ) }
       
      Parameters:
      self - any Object
      format - A format string
      arg - Argument which is referenced by the format specifiers in the format string. The type of arg should be one of Object[], List, int[], short[], byte[], char[], boolean[], long[], float[], or double[].
      Since:
      1.0
    • sprintf

      public static String sprintf(Object self, String format, Object[] values)
      Sprintf to a string.
      Parameters:
      self - any Object
      format - a format string
      values - values referenced by the format specifiers in the format string
      Returns:
      the resulting formatted string
      Since:
      1.5.0
    • sprintf

      public static String sprintf(Object self, String format, Object arg)
      Returns a formatted string using the specified format string and arguments.
      Parameters:
      self - any Object
      format - A format string
      arg - Argument which is referenced by the format specifiers in the format string. The type of arg should be one of Object[], List, int[], short[], byte[], char[], boolean[], long[], float[], or double[].
      Returns:
      the resulting printf'd string
      Since:
      1.5.0
    • isCase

      public static boolean isCase(Object caseValue, Object switchValue)
      Method for overloading the behavior of the 'case' method in switch statements. The default implementation handles arrays types but otherwise simply delegates to Object#equals, but this may be overridden for other types. In this example:
       switch( a ) {
         case b: //some code
       }
      "some code" is called when b.isCase( a ) returns true.
      Parameters:
      caseValue - the case value
      switchValue - the switch value
      Returns:
      true if the switchValue is deemed to be equal to the caseValue
      Since:
      1.0
    • isCase

      public static boolean isCase(Class caseValue, Object switchValue)
      Special 'Case' implementation for Class, which allows testing whether some switch value is assignable from the given case class. If the switch value is an object, isCase will return true if the switch value is assignment compatible with the class (case value), i.e. is an instanceof the class, for example:
       def someList = []
       switch (someList) {
         case List:
           assert true : 'is a list'
           break
         case Map:
           assert false : 'is not a Map'
           break
         default:
           assert false : 'should never get here'
           break
       }
       
      If the switch value is a class, isCase will return true if the switch value is assignable from the given class (case value), i.e. the case class is the same as, or a superclass, or a super-interface of the switch class, for example:
       switch (ArrayList) {
         case List:
           assert true : 'is a list'
           break
         case Map:
           assert false : 'is not a Map'
           break
         default:
           assert false : 'should never get here'
           break
       }
       
      Parameters:
      caseValue - the case value
      switchValue - the switch value
      Returns:
      true if the switchValue is deemed to be assignable from the given class
      Since:
      1.0
    • isCase

      public static boolean isCase(Collection caseValue, Object switchValue)
      'Case' implementation for collections which tests if the 'switch' operand is contained in any of the 'case' values. For example:
      switch( 3 ) {
         case [1,3,5]:
           assert true
           break
         default:
           assert false
       }
      Parameters:
      caseValue - the case value
      switchValue - the switch value
      Returns:
      true if the caseValue is deemed to contain the switchValue
      Since:
      1.0
      See Also:
    • isCase

      public static boolean isCase(Map caseValue, Object switchValue)
      'Case' implementation for maps which tests the groovy truth value obtained using the 'switch' operand as key. For example:
      switch( 'foo' ) {
         case [foo:true, bar:false]:
           assert true
           break
         default:
           assert false
       }
      Parameters:
      caseValue - the case value
      switchValue - the switch value
      Returns:
      the groovy truth value from caseValue corresponding to the switchValue key
      Since:
      1.7.6
    • isCase

      public static boolean isCase(Number caseValue, Number switchValue)
      Special 'case' implementation for all numbers, which delegates to the compareTo() method for comparing numbers of different types.
      Parameters:
      caseValue - the case value
      switchValue - the switch value
      Returns:
      true if the numbers are deemed equal
      Since:
      1.5.0
    • isNotCase

      public static boolean isNotCase(Number caseValue, Number switchValue)
      Since:
      4.0.0
    • isNotCase

      public static boolean isNotCase(Object caseValue, Object switchValue)
      Since:
      4.0.0
    • isNotCase

      public static boolean isNotCase(Class<?> caseValue, Object switchValue)
      Since:
      4.0.0
    • isNotCase

      public static boolean isNotCase(Closure<?> caseValue, Object switchValue)
      Since:
      4.0.0
    • isNotCase

      public static boolean isNotCase(Collection<?> caseValue, Object switchValue)
      Since:
      4.0.0
    • isNotCase

      public static boolean isNotCase(Map<?,?> caseValue, Object switchValue)
      Since:
      4.0.0
    • unique

      public static <T> Iterator<T> unique(Iterator<T> self)
      Returns an iterator equivalent to this iterator with all duplicated items removed by using Groovy's default number-aware comparator. The original iterator will become exhausted of elements after determining the unique values. A new iterator for the unique values will be returned.
      Parameters:
      self - an Iterator
      Returns:
      a new Iterator of the unique items from the original iterator
      Since:
      1.5.5
    • unique

      public static <T> Collection<T> unique(Collection<T> self)
      Modifies this collection to remove all duplicated items, using Groovy's default number-aware comparator.
      assert [1,3] == [1,3,3].unique()
      Parameters:
      self - a collection
      Returns:
      the now modified collection
      Since:
      1.0
      See Also:
    • unique

      public static <T> List<T> unique(List<T> self)
      Modifies this List to remove all duplicated items, using Groovy's default number-aware comparator.
      assert [1,3] == [1,3,3].unique()
      Parameters:
      self - a List
      Returns:
      the now modified List
      Since:
      2.4.0
      See Also:
    • unique

      public static <T> Collection<T> unique(Collection<T> self, boolean mutate)
      Remove all duplicates from a given Collection using Groovy's default number-aware comparator. If mutate is true, it works by modifying the original object (and also returning it). If mutate is false, a new collection is returned leaving the original unchanged.
       assert [1,3] == [1,3,3].unique()
       
       def orig = [1, 3, 2, 3]
       def uniq = orig.unique(false)
       assert orig == [1, 3, 2, 3]
       assert uniq == [1, 3, 2]
       
      Parameters:
      self - a collection
      mutate - false will cause a new list containing unique items from the collection to be created, true will mutate collections in place
      Returns:
      the now modified collection
      Since:
      1.8.1
    • unique

      public static <T> List<T> unique(List<T> self, boolean mutate)
      Remove all duplicates from a given List using Groovy's default number-aware comparator. If mutate is true, it works by modifying the original object (and also returning it). If mutate is false, a new collection is returned leaving the original unchanged.
       assert [1,3] == [1,3,3].unique()
       
       def orig = [1, 3, 2, 3]
       def uniq = orig.unique(false)
       assert orig == [1, 3, 2, 3]
       assert uniq == [1, 3, 2]
       
      Parameters:
      self - a List
      mutate - false will cause a new List containing unique items from the List to be created, true will mutate List in place
      Returns:
      the now modified List
      Since:
      2.4.0
    • numberAwareCompareTo

      public static int numberAwareCompareTo(Comparable self, Comparable other)
      Provides a method that compares two comparables using Groovy's default number aware comparator.
      Parameters:
      self - a Comparable
      other - another Comparable
      Returns:
      a -ve number, 0 or a +ve number according to Groovy's compareTo contract
      Since:
      1.6.0
    • unique

      public static <T> Iterator<T> unique(Iterator<T> self, Closure condition)
      Returns an iterator equivalent to this iterator but with all duplicated items removed by using a Closure to determine duplicate (equal) items. The original iterator will be fully processed after the call.

      If the closure takes a single parameter, the argument passed will be each element, and the closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the Iterator will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

      Parameters:
      self - an Iterator
      condition - a Closure used to determine unique items
      Returns:
      the modified Iterator
      Since:
      1.5.5
    • unique

      public static <T> Collection<T> unique(Collection<T> self, Closure closure)
      A convenience method for making a collection unique using a Closure to determine duplicate (equal) items.

      If the closure takes a single parameter, the argument passed will be each element, and the closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the collection will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

      assert [1,4] == [1,3,4,5].unique { it % 2 }
      assert [2,3,4] == [2,3,3,4].unique { a, b -> a <=> b }
      Parameters:
      self - a Collection
      closure - a 1 or 2 arg Closure used to determine unique items
      Returns:
      self without any duplicates
      Since:
      1.0
      See Also:
    • unique

      public static <T> List<T> unique(List<T> self, Closure closure)
      A convenience method for making a List unique using a Closure to determine duplicate (equal) items.

      If the closure takes a single parameter, the argument passed will be each element, and the closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the List will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

      assert [1,4] == [1,3,4,5].unique { it % 2 }
      assert [2,3,4] == [2,3,3,4].unique { a, b -> a <=> b }
      Parameters:
      self - a List
      closure - a 1 or 2 arg Closure used to determine unique items
      Returns:
      self without any duplicates
      Since:
      2.4.0
      See Also:
    • unique

      public static <T> Collection<T> unique(Collection<T> self, boolean mutate, Closure closure)
      A convenience method for making a collection unique using a Closure to determine duplicate (equal) items. If mutate is true, it works on the receiver object and returns it. If mutate is false, a new collection is returned.

      If the closure takes a single parameter, each element from the Collection will be passed to the closure. The closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the collection will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

       def orig = [1, 3, 4, 5]
       def uniq = orig.unique(false) { it % 2 }
       assert orig == [1, 3, 4, 5]
       assert uniq == [1, 4]
       
       def orig = [2, 3, 3, 4]
       def uniq = orig.unique(false) { a, b -> a <=> b }
       assert orig == [2, 3, 3, 4]
       assert uniq == [2, 3, 4]
       
      Parameters:
      self - a Collection
      mutate - false will always cause a new list to be created, true will mutate lists in place
      closure - a 1 or 2 arg Closure used to determine unique items
      Returns:
      self without any duplicates
      Since:
      1.8.1
    • unique

      public static <T> List<T> unique(List<T> self, boolean mutate, Closure closure)
      A convenience method for making a List unique using a Closure to determine duplicate (equal) items. If mutate is true, it works on the receiver object and returns it. If mutate is false, a new collection is returned.

      If the closure takes a single parameter, each element from the List will be passed to the closure. The closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the collection will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

       def orig = [1, 3, 4, 5]
       def uniq = orig.unique(false) { it % 2 }
       assert orig == [1, 3, 4, 5]
       assert uniq == [1, 4]
       
       def orig = [2, 3, 3, 4]
       def uniq = orig.unique(false) { a, b -> a <=> b }
       assert orig == [2, 3, 3, 4]
       assert uniq == [2, 3, 4]
       
      Parameters:
      self - a List
      mutate - false will always cause a new list to be created, true will mutate lists in place
      closure - a 1 or 2 arg Closure used to determine unique items
      Returns:
      self without any duplicates
      Since:
      2.4.0
    • unique

      public static <T> Iterator<T> unique(Iterator<T> self, Comparator<? super T> comparator)
      Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator. The original iterator will be exhausted upon returning.
      Parameters:
      self - an Iterator
      comparator - a Comparator
      Returns:
      the modified Iterator
      Since:
      1.5.5
    • unique

      public static <T> Collection<T> unique(Collection<T> self, Comparator<? super T> comparator)
      Remove all duplicates from a given Collection. Works on the original object (and also returns it). The order of members in the Collection are compared by the given Comparator. For each duplicate, the first member which is returned by the given Collection's iterator is retained, but all other ones are removed. The given Collection's original order is preserved.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.unique(new PersonComparator())
       assert( list2 == list && list == [a, b, c] )
       
      Parameters:
      self - a Collection
      comparator - a Comparator
      Returns:
      self the now modified collection without duplicates
      Since:
      1.0
      See Also:
    • unique

      public static <T> List<T> unique(List<T> self, Comparator<? super T> comparator)
      Remove all duplicates from a given List. Works on the original object (and also returns it). The order of members in the List are compared by the given Comparator. For each duplicate, the first member which is returned by the given List's iterator is retained, but all other ones are removed. The given List's original order is preserved.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.unique(new PersonComparator())
       assert( list2 == list && list == [a, b, c] )
       
      Parameters:
      self - a List
      comparator - a Comparator
      Returns:
      self the now modified List without duplicates
      Since:
      2.4.0
      See Also:
    • unique

      public static <T> Collection<T> unique(Collection<T> self, boolean mutate, Comparator<? super T> comparator)
      Remove all duplicates from a given Collection. If mutate is true, it works on the original object (and also returns it). If mutate is false, a new collection is returned. The order of members in the Collection are compared by the given Comparator. For each duplicate, the first member which is returned by the given Collection's iterator is retained, but all other ones are removed. The given Collection's original order is preserved.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.unique(false, new PersonComparator())
       assert( list2 != list && list2 == [a, b, c] )
       
      Parameters:
      self - a Collection
      mutate - false will always cause a new collection to be created, true will mutate collections in place
      comparator - a Comparator
      Returns:
      self the collection without duplicates
      Since:
      1.8.1
    • unique

      public static <T> List<T> unique(List<T> self, boolean mutate, Comparator<? super T> comparator)
      Remove all duplicates from a given List. If mutate is true, it works on the original object (and also returns it). If mutate is false, a new List is returned. The order of members in the List are compared by the given Comparator. For each duplicate, the first member which is returned by the given List's iterator is retained, but all other ones are removed. The given List's original order is preserved.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.unique(false, new PersonComparator())
       assert( list2 != list && list2 == [a, b, c] )
       
      Parameters:
      self - a List
      mutate - false will always cause a new List to be created, true will mutate List in place
      comparator - a Comparator
      Returns:
      self the List without duplicates
      Since:
      2.4.0
    • toUnique

      public static <T> Iterator<T> toUnique(Iterator<T> self, Closure condition)
      Returns an iterator equivalent to this iterator but with all duplicated items removed where duplicate (equal) items are deduced by calling the supplied Closure condition.

      If the supplied Closure takes a single parameter, the argument passed will be each element, and the closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the Iterator will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

       def items = "Hello".toList() + [null, null] + "there".toList()
       def toLower = { it == null ? null : it.toLowerCase() }
       def noDups = items.iterator().toUnique(toLower).toList()
       assert noDups == ['H', 'e', 'l', 'o', null, 't', 'r']
       
      assert [1,4] == [1,3,4,5].toUnique { it % 2 }
      assert [2,3,4] == [2,3,3,4].toUnique { a, b -> a <=> b }
      Parameters:
      self - an Iterator
      condition - a Closure used to determine unique items
      Returns:
      an Iterator with no duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> Iterator<T> toUnique(Iterator<T> self, Comparator<? super T> comparator)
      Returns an iterator equivalent to this iterator with all duplicated items removed by using the supplied comparator.
      Parameters:
      self - an Iterator
      comparator - a Comparator used to determine unique (equal) items If null, the Comparable natural ordering of the elements will be used.
      Returns:
      an Iterator with no duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> Iterator<T> toUnique(Iterator<T> self)
      Returns an iterator equivalent to this iterator with all duplicated items removed by using the natural ordering of the items.
      Parameters:
      self - an Iterator
      Returns:
      an Iterator with no duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> Collection<T> toUnique(Iterable<T> self, Comparator<? super T> comparator)
      Returns a Collection containing the items from the Iterable but with duplicates removed. The items in the Iterable are compared by the given Comparator. For each duplicate, the first member which is returned from the Iterable is retained, but all other ones are removed.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.toUnique(new PersonComparator())
       assert list2 == [a, b, c] && list == [a, b, c, d]
       
      Parameters:
      self - an Iterable
      comparator - a Comparator used to determine unique (equal) items If null, the Comparable natural ordering of the elements will be used.
      Returns:
      the Collection of non-duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> List<T> toUnique(List<T> self, Comparator<? super T> comparator)
      Returns a List containing the items from the List but with duplicates removed. The items in the List are compared by the given Comparator. For each duplicate, the first member which is returned from the List is retained, but all other ones are removed.

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       class PersonComparator implements Comparator {
           int compare(Object o1, Object o2) {
               Person p1 = (Person) o1
               Person p2 = (Person) o2
               if (p1.lname != p2.lname)
                   return p1.lname.compareTo(p2.lname)
               else
                   return p1.fname.compareTo(p2.fname)
           }
      
           boolean equals(Object obj) {
               return this.equals(obj)
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       List list2 = list.toUnique(new PersonComparator())
       assert list2 == [a, b, c] && list == [a, b, c, d]
       
      Parameters:
      self - a List
      comparator - a Comparator used to determine unique (equal) items If null, the Comparable natural ordering of the elements will be used.
      Returns:
      the List of non-duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> Collection<T> toUnique(Iterable<T> self)
      Returns a Collection containing the items from the Iterable but with duplicates removed using the natural ordering of the items to determine uniqueness.

       String[] letters = ['c', 'a', 't', 's', 'a', 't', 'h', 'a', 't']
       String[] expected = ['c', 'a', 't', 's', 'h']
       assert letters.toUnique() == expected
       
      Parameters:
      self - an Iterable
      Returns:
      the Collection of non-duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> List<T> toUnique(List<T> self)
      Returns a List containing the items from the List but with duplicates removed using the natural ordering of the items to determine uniqueness.

       def letters = ['c', 'a', 't', 's', 'a', 't', 'h', 'a', 't']
       def expected = ['c', 'a', 't', 's', 'h']
       assert letters.toUnique() == expected
       
      Parameters:
      self - a List
      Returns:
      the List of non-duplicate items
      Since:
      2.4.0
    • toUnique

      public static <T> Collection<T> toUnique(Iterable<T> self, Closure condition)
      Returns a Collection containing the items from the Iterable but with duplicates removed. The items in the Iterable are compared by the given Closure condition. For each duplicate, the first member which is returned from the Iterable is retained, but all other ones are removed.

      If the closure takes a single parameter, each element from the Iterable will be passed to the closure. The closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the Iterable will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       def list2 = list.toUnique{ p1, p2 -> p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname }
       assert( list2 == [a, b, c] && list == [a, b, c, d] )
       def list3 = list.toUnique{ it.toString() }
       assert( list3 == [a, b, c] && list == [a, b, c, d] )
       
      Parameters:
      self - an Iterable
      condition - a Closure used to determine unique items
      Returns:
      a new Collection
      Since:
      2.4.0
      See Also:
    • toUnique

      public static <T> List<T> toUnique(List<T> self, Closure condition)
      Returns a List containing the items from the List but with duplicates removed. The items in the List are compared by the given Closure condition. For each duplicate, the first member which is returned from the Iterable is retained, but all other ones are removed.

      If the closure takes a single parameter, each element from the Iterable will be passed to the closure. The closure should return a value used for comparison (either using Comparable.compareTo(java.lang.Object) or Object.equals(java.lang.Object)). If the closure takes two parameters, two items from the Iterable will be passed as arguments, and the closure should return an int value (with 0 indicating the items are not unique).

       class Person {
           def fname, lname
           String toString() {
               return fname + " " + lname
           }
       }
      
       Person a = new Person(fname:"John", lname:"Taylor")
       Person b = new Person(fname:"Clark", lname:"Taylor")
       Person c = new Person(fname:"Tom", lname:"Cruz")
       Person d = new Person(fname:"Clark", lname:"Taylor")
      
       def list = [a, b, c, d]
       def list2 = list.toUnique{ p1, p2 -> p1.lname != p2.lname ? p1.lname <=> p2.lname : p1.fname <=> p2.fname }
       assert( list2 == [a, b, c] && list == [a, b, c, d] )
       def list3 = list.toUnique{ it.toString() }
       assert( list3 == [a, b, c] && list == [a, b, c, d] )
       
      Parameters:
      self - a List
      condition - a Closure used to determine unique items
      Returns:
      a new List
      Since:
      2.4.0
      See Also:
    • toUnique

      public static <T> T[] toUnique(T[] self, Comparator<? super T> comparator)
      Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.

       String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T']
       String[] lower = ['c', 'a', 't', 's', 'h']
       class LowerComparator implements Comparator {
           int compare(let1, let2) { let1.toLowerCase() <=> let2.toLowerCase() }
       }
       assert letters.toUnique(new LowerComparator()) == lower
       
      Parameters:
      self - an array
      comparator - a Comparator used to determine unique (equal) items If null, the Comparable natural ordering of the elements will be used.
      Returns:
      the unique items from the array
    • toUnique

      public static <T> T[] toUnique(T[] self)
      Returns a new Array containing the items from the original Array but with duplicates removed using the natural ordering of the items in the array.

       String[] letters = ['c', 'a', 't', 's', 'a', 't', 'h', 'a', 't']
       String[] expected = ['c', 'a', 't', 's', 'h']
       def result = letters.toUnique()
       assert result == expected
       assert result.class.componentType == String
       
      Parameters:
      self - an array
      Returns:
      the unique items from the array
    • toUnique

      public static <T> T[] toUnique(T[] self, Closure condition)
      Returns a new Array containing the items from the original Array but with duplicates removed with the supplied comparator determining which items are unique.

       String[] letters = ['c', 'a', 't', 's', 'A', 't', 'h', 'a', 'T']
       String[] expected = ['c', 'a', 't', 's', 'h']
       assert letters.toUnique{ p1, p2 -> p1.toLowerCase() <=> p2.toLowerCase() } == expected
       assert letters.toUnique{ it.toLowerCase() } == expected
       
      Parameters:
      self - an array
      condition - a Closure used to determine unique items
      Returns:
      the unique items from the array
    • each

      public static <T> T[] each(T[] self, Closure closure)
      Iterates through an array passing each array entry to the given closure.
       String[] letters = ['a', 'b', 'c']
       String result = ''
       letters.each{ result += it }
       assert result == 'abc'
       
      Parameters:
      self - the array over which we iterate
      closure - the closure applied on each array entry
      Returns:
      the self array
      Since:
      2.5.0
    • each

      public static <T> T each(T self, Closure closure)
      Iterates through an aggregate type or data structure, passing each item to the given closure. Custom types may utilize this method by simply providing an "iterator()" method. The items returned from the resulting iterator will be passed to the closure.
       String result = ''
       ['a', 'b', 'c'].each{ result += it }
       assert result == 'abc'
       
      Parameters:
      self - the object over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self Object
      Since:
      1.0
    • eachWithIndex

      public static <T> T[] eachWithIndex(T[] self, Closure closure)
      Iterates through an array, passing each array element and the element's index (a counter starting at zero) to the given closure.
       String[] letters = ['a', 'b', 'c']
       String result = ''
       letters.eachWithIndex{ letter, index -> result += "$index:$letter" }
       assert result == '0:a1:b2:c'
       
      Parameters:
      self - an array
      closure - a Closure to operate on each array entry
      Returns:
      the self array
      Since:
      2.5.0
    • eachWithIndex

      public static <T> T eachWithIndex(T self, Closure closure)
      Iterates through an aggregate type or data structure, passing each item and the item's index (a counter starting at zero) to the given closure.
       String result = ''
       ['a', 'b', 'c'].eachWithIndex{ letter, index -> result += "$index:$letter" }
       assert result == '0:a1:b2:c'
       
      Parameters:
      self - an Object
      closure - a Closure to operate on each item
      Returns:
      the self Object
      Since:
      1.0
    • eachWithIndex

      public static <T> Iterable<T> eachWithIndex(Iterable<T> self, Closure closure)
      Iterates through an iterable type, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - an Iterable
      closure - a Closure to operate on each item
      Returns:
      the self Iterable
      Since:
      2.3.0
    • eachWithIndex

      public static <T> Iterator<T> eachWithIndex(Iterator<T> self, Closure closure)
      Iterates through an iterator type, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - an Iterator
      closure - a Closure to operate on each item
      Returns:
      the self Iterator (now exhausted)
      Since:
      2.3.0
    • eachWithIndex

      public static <T> Collection<T> eachWithIndex(Collection<T> self, Closure closure)
      Iterates through a Collection, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - a Collection
      closure - a Closure to operate on each item
      Returns:
      the self Collection
      Since:
      2.4.0
    • eachWithIndex

      public static <T> List<T> eachWithIndex(List<T> self, Closure closure)
      Iterates through a List, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - a List
      closure - a Closure to operate on each item
      Returns:
      the self List
      Since:
      2.4.0
    • eachWithIndex

      public static <T> Set<T> eachWithIndex(Set<T> self, Closure closure)
      Iterates through a Set, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - a Set
      closure - a Closure to operate on each item
      Returns:
      the self Set
      Since:
      2.4.0
    • eachWithIndex

      public static <T> SortedSet<T> eachWithIndex(SortedSet<T> self, Closure closure)
      Iterates through a SortedSet, passing each item and the item's index (a counter starting at zero) to the given closure.
      Parameters:
      self - a SortedSet
      closure - a Closure to operate on each item
      Returns:
      the self SortedSet
      Since:
      2.4.0
    • each

      public static <T> Iterable<T> each(Iterable<T> self, Closure closure)
      Iterates through an Iterable, passing each item to the given closure.
      Parameters:
      self - the Iterable over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self Iterable
    • each

      public static <T> Iterator<T> each(Iterator<T> self, Closure closure)
      Iterates through an Iterator, passing each item to the given closure.
      Parameters:
      self - the Iterator over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self Iterator
      Since:
      2.4.0
    • each

      public static <T> Collection<T> each(Collection<T> self, Closure closure)
      Iterates through a Collection, passing each item to the given closure.
      Parameters:
      self - the Collection over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self Collection
      Since:
      2.4.0
    • each

      public static <T> List<T> each(List<T> self, Closure closure)
      Iterates through a List, passing each item to the given closure.
      Parameters:
      self - the List over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self List
      Since:
      2.4.0
    • each

      public static <T> Set<T> each(Set<T> self, Closure closure)
      Iterates through a Set, passing each item to the given closure.
      Parameters:
      self - the Set over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self Set
      Since:
      2.4.0
    • each

      public static <T> SortedSet<T> each(SortedSet<T> self, Closure closure)
      Iterates through a SortedSet, passing each item to the given closure.
      Parameters:
      self - the SortedSet over which we iterate
      closure - the closure applied on each element found
      Returns:
      the self SortedSet
      Since:
      2.4.0
    • each

      public static <K, V> Map<K,V> each(Map<K,V> self, Closure<?> closure)
      Allows a Map to be iterated through using a closure. If the closure takes one parameter then it will be passed the Map.Entry otherwise if the closure takes two parameters then it will be passed the key and the value.
      def result = ""
       [a:1, b:3].each { key, value -> result += "$key$value" }
       assert result == "a1b3"
      def result = ""
       [a:1, b:3].each { entry -> result += entry }
       assert result == "a=1b=3"
      In general, the order in which the map contents are processed cannot be guaranteed. In practise, specialized forms of Map, e.g. a TreeMap will have its contents processed according to the natural ordering of the map.
      Parameters:
      self - the map over which we iterate
      closure - the 1 or 2 arg closure applied on each entry of the map
      Returns:
      returns the self parameter
      Since:
      1.5.0
    • reverseEach

      public static <K, V> Map<K,V> reverseEach(Map<K,V> self, Closure<?> closure)
      Allows a Map to be iterated through in reverse order using a closure. In general, the order in which the map contents are processed cannot be guaranteed. In practise, specialized forms of Map, e.g. a TreeMap will have its contents processed according to the reverse of the natural ordering of the map.
      Parameters:
      self - the map over which we iterate
      closure - the 1 or 2 arg closure applied on each entry of the map
      Returns:
      returns the self parameter
      Since:
      1.7.2
      See Also:
    • eachWithIndex

      public static <K, V> Map<K,V> eachWithIndex(Map<K,V> self, Closure<?> closure)
      Allows a Map to be iterated through using a closure. If the closure takes two parameters then it will be passed the Map.Entry and the item's index (a counter starting at zero) otherwise if the closure takes three parameters then it will be passed the key, the value, and the index.
      def result = ""
       [a:1, b:3].eachWithIndex { key, value, index -> result += "$index($key$value)" }
       assert result == "0(a1)1(b3)"
      def result = ""
       [a:1, b:3].eachWithIndex { entry, index -> result += "$index($entry)" }
       assert result == "0(a=1)1(b=3)"
      Parameters:
      self - the map over which we iterate
      closure - a 2 or 3 arg Closure to operate on each item
      Returns:
      the self Object
      Since:
      1.5.0
    • reverseEach

      public static <T> List<T> reverseEach(List<T> self, Closure closure)
      Iterate over each element of the list in the reverse order.
      def result = []
       [1,2,3].reverseEach { result << it }
       assert result == [3,2,1]
      Parameters:
      self - a List
      closure - a closure to which each item is passed.
      Returns:
      the original list
      Since:
      1.5.0
    • reverseEach

      public static <T> T[] reverseEach(T[] self, Closure closure)
      Iterate over each element of the array in the reverse order.
      Parameters:
      self - an array
      closure - a closure to which each item is passed
      Returns:
      the original array
      Since:
      1.5.2
    • reverseEach

      public static <T> NavigableSet<T> reverseEach(NavigableSet<T> self, Closure closure)
      Iterate over each element of the set in reverse order.
       TreeSet navSet = [2, 4, 1, 3]  // natural order is sorted
       List result = []
       navSet.reverseEach { result << it }
       assert result == [4, 3, 2, 1]
       
      Parameters:
      self - a NavigableSet
      closure - a closure to which each item is passed.
      Returns:
      the original NavigableSet
      Since:
      4.0.11
    • every

      public static boolean every(Object self, Closure predicate)
      Used to determine if the given predicate closure is valid (i.e. returns true for all items in this data structure). A simple example for a list:
      def list = [3,4,5]
       def greaterThanTwo = list.every { it > 2 }
       
      Parameters:
      self - the object over which we iterate
      predicate - the closure predicate used for matching
      Returns:
      true if every iteration of the object matches the closure predicate
      Since:
      1.0
    • every

      public static <T> boolean every(Iterator<T> self, Closure predicate)
      Used to determine if the given predicate closure is valid (i.e. returns true for all items in this iterator). A simple example for a list:
      def list = [3,4,5]
       def greaterThanTwo = list.iterator().every { it > 2 }
       
      Parameters:
      self - the iterator over which we iterate
      predicate - the closure predicate used for matching
      Returns:
      true if every iteration of the object matches the closure predicate
      Since:
      2.3.0
    • every

      public static <T> boolean every(T[] self, Closure predicate)
      Used to determine if the given predicate closure is valid (i.e. returns true for all items in this Array).
      Parameters:
      self - an Array
      predicate - the closure predicate used for matching
      Returns:
      true if every element of the Array matches the closure predicate
      Since:
      2.5.0
    • every

      public static <T> boolean every(Iterable<T> self, Closure predicate)
      Used to determine if the given predicate closure is valid (i.e. returns true for all items in this iterable). A simple example for a list:
      def list = [3,4,5]
       def greaterThanTwo = list.every { it > 2 }
       
      Parameters:
      self - the iterable over which we iterate
      predicate - the closure predicate used for matching
      Returns:
      true if every iteration of the object matches the closure predicate
      Since:
      2.3.0
    • every

      public static <K, V> boolean every(Map<K,V> self, Closure predicate)
      Iterates over the entries of a map, and checks whether a predicate is valid for all entries. If the closure takes one parameter then it will be passed the Map.Entry otherwise if the closure takes two parameters then it will be passed the key and the value.
      def map = [a:1, b:2.0, c:2L]
       assert !map.every { key, value -> value instanceof Integer }
       assert map.every { entry -> entry.value instanceof Number }
      Parameters:
      self - the map over which we iterate
      predicate - the 1 or 2 arg Closure predicate used for matching
      Returns:
      true if every entry of the map matches the closure predicate
      Since:
      1.5.0
    • every

      public static boolean every(Object self)
      Iterates over every element of a collection, and checks whether all elements are true according to the Groovy Truth. Equivalent to self.every({element -> element})
       assert [true, true].every()
       assert [1, 1].every()
       assert ![1, 0].every()
       
      Parameters:
      self - the object over which we iterate
      Returns:
      true if every item in the collection matches satisfies Groovy truth
      Since:
      1.5.0
    • any

      public static boolean any(Object self, Closure predicate)
      Iterates over the contents of an object or collection, and checks whether a predicate is valid for at least one element.
       assert [1, 2, 3].any { it == 2 }
       assert ![1, 2, 3].any { it > 3 }
       
      Parameters:
      self - the object over which we iterate
      predicate - the closure predicate used for matching
      Returns:
      true if any iteration for the object matches the closure predicate
      Since:
      1.0
    • any

      public static <T> boolean any