public class Sequence
extends ArrayList
implements GroovyObject
Represents a sequence of zero or more objects of a given type. The type can be omitted in which case any type of object can be added.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
add(int index, Object element)Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
|
|
public boolean |
add(Object element)Appends the specified element to the end of this list.
|
|
public boolean |
addAll(Collection c)Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list is nonempty.)
|
|
public boolean |
addAll(int index, Collection c)Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
|
|
protected void |
checkCollectionType(Collection c)Checks that each member of the given collection are of the correct type |
|
protected void |
checkType(Object object)Checks that the given object instance is of the correct type otherwise a runtime exception is thrown |
|
public void |
clear()Removes all of the elements from this list. The list will be empty after this call returns. |
|
public boolean |
equals(Object that)Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both
lists have the same size, and all corresponding pairs of elements in
the two lists are equal. (Two elements e1 and
e2 are equal if (e1==null ? e2==null :
e1.equals(e2)).) In other words, two lists are defined to be
equal if they contain the same elements in the same order.
|
|
public boolean |
equals(Sequence that)Compares this sequence with another sequence using Groovy equality. |
|
public MetaClass |
getMetaClass()* Returns the metaclass for a given class. * *
|
|
public Object |
getProperty(String property)* Retrieves a property value. * *
|
|
public int |
hashCode()Returns the hash code value for this list.
|
|
public Object |
invokeMethod(String name, Object args)* Invokes the given method. * *
|
|
public int |
minimumSize()Returns the minimum allowed size for this sequence. |
|
public Object |
remove(int index)Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).
|
|
protected void |
removeRange(int fromIndex, int toIndex)Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
Shifts any succeeding elements to the left (reduces their index).
This call shortens the list by (toIndex - fromIndex) elements.
(If toIndex==fromIndex, this operation has no effect.)
|
|
public void |
set(Collection collection)Sets the contents of this sequence to that of the given collection. |
|
public Object |
set(int index, Object element)Replaces the element at the specified position in this list with the specified element.
|
|
public void |
setMetaClass(MetaClass metaClass)* Allows the MetaClass to be replaced with a derived implementation. * *
|
|
public void |
setProperty(String property, Object newValue)* Sets the given property to the new value. * *
|
|
public Class |
type()
|
| Methods inherited from class | Name |
|---|---|
class ArrayList |
add, add, addAll, addAll, clear, clone, contains, containsAll, ensureCapacity, equals, forEach, get, getClass, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, notify, notifyAll, parallelStream, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, stream, subList, toArray, toArray, toArray, toString, trimToSize, wait, wait, wait |
Creates a sequence with no type restriction.
Creates a sequence constrained to the supplied type.
type - the allowed element typeInserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
add operation
is not supported by this listindex < 0 || index > size())add operation
is not supported by this listindex < 0 || index > size())add operation
is not supported by this listindex < 0 || index > size())add operation
is not supported by this listindex < 0 || index > size())add operation
is not supported by this listindex < 0 || index > size())add operation
is not supported by this listindex < 0 || index > size())index - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedindex - index at which the specified element is to be insertedelement - element to be insertedUnsupportedOperationException.Appends the specified element to the end of this list.
e - element to be appended to this listtrue (as specified by Collection.add)Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list is nonempty.)
c - collection containing elements to be added to this listtrue if this list changed as a result of the callInserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.
addAll operation
is not supported by this listindex < 0 || index > size())addAll operation
is not supported by this listindex < 0 || index > size())addAll operation
is not supported by this listindex < 0 || index > size())addAll operation
is not supported by this listindex < 0 || index > size())addAll operation
is not supported by this listindex < 0 || index > size())addAll operation
is not supported by this listindex < 0 || index > size())index - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listindex - index at which to insert the first element from the
specified collectionc - collection containing elements to be added to this listtrue if this list changed as a result of the calltrue if this list changed as a result of the calltrue if this list changed as a result of the calltrue if this list changed as a result of the calltrue if this list changed as a result of the calltrue if this list changed as a result of the calltrue if this list changed as a result of the calladd(int, E).
Many implementations will override this method for efficiency.
Note that this implementation throws an
UnsupportedOperationException unless
add(int, Object) add(int, E) is overridden.
Checks that each member of the given collection are of the correct type
Checks that the given object instance is of the correct type otherwise a runtime exception is thrown
Removes all of the elements from this list. The list will be empty after this call returns.
Compares the specified object with this list for equality. Returns
true if and only if the specified object is also a list, both
lists have the same size, and all corresponding pairs of elements in
the two lists are equal. (Two elements e1 and
e2 are equal if (e1==null ? e2==null :
e1.equals(e2)).) In other words, two lists are defined to be
equal if they contain the same elements in the same order.
true; if not, it checks if the
specified object is a list. If not, it returns false; if so,
it iterates over both lists, comparing corresponding pairs of elements.
If any comparison returns false, this method returns
false. If either iterator runs out of elements before the
other it returns false (as the lists are of unequal length);
otherwise it returns true when the iterations complete.o - the object to be compared for equality with this listtrue if the specified object is equal to this listCompares this sequence with another sequence using Groovy equality.
that - the other sequencetrue if the sequences are equal* Returns the metaclass for a given class. * *
* Retrieves a property value. * *
propertyName - the name of the property of interest
*Returns the hash code value for this list.
* Invokes the given method. * *
name - the name of the method to call
*args - the arguments to use for the method call
*Returns the minimum allowed size for this sequence.
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).
remove operation
is not supported by this listindex < 0 || index >= size())remove operation
is not supported by this listindex < 0 || index >= size())remove operation
is not supported by this listindex < 0 || index >= size())index - the index of the element to be removedindex - the index of the element to be removedindex - the index of the element to be removedindex - the index of the element to be removedUnsupportedOperationException. Removes from this list all of the elements whose index is between
fromIndex, inclusive, and toIndex, exclusive.
Shifts any succeeding elements to the left (reduces their index).
This call shortens the list by (toIndex - fromIndex) elements.
(If toIndex==fromIndex, this operation has no effect.)
fromIndex or
toIndex is out of range
(fromIndex < 0 ||
toIndex > size() ||
toIndex < fromIndex)Sets the contents of this sequence to that of the given collection.
Replaces the element at the specified position in this list with the specified element.
set operation
is not supported by this listindex < 0 || index >= size())set operation
is not supported by this listindex < 0 || index >= size())set operation
is not supported by this listindex < 0 || index >= size())set operation
is not supported by this listindex < 0 || index >= size())set operation
is not supported by this listindex < 0 || index >= size())set operation
is not supported by this listindex < 0 || index >= size())index - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionindex - index of the element to replaceelement - element to be stored at the specified positionUnsupportedOperationException.* Allows the MetaClass to be replaced with a derived implementation. * *
metaClass - the new metaclass* Sets the given property to the new value. * *
propertyName - the name of the property of interest
*newValue - the new value for the property
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.