Top Description Fields Constructors Methods
groovy.lang

public Class Sequence

extends ArrayList
implements GroovyObject
Class Inheritance
All Implemented Interfaces
groovy.lang.GroovyObject
Known Direct Subclasses
groovy.lang.NonEmptySequence
Imports
org.codehaus.groovy.runtime.InvokerHelper, org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation, java.util.ArrayList, .Collection, .List

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.

Field Summary

Modifier and TypeField and Description
private int
private transient MetaClass
private static final long
private final Class<T>

Constructor Summary

AccessConstructor and Description
public
public
Sequence(Class<T> type)

public
Sequence(Class<T> type, List<E> content)

Method Summary

Modifier and TypeMethod and Description
public void
add(int
index at which the specified element is to be inserted
index
,
Object
element to be inserted
element
)

Overrides java.util.ArrayList.add.

Implements java.util.List.add.

Inserts the specified element at the specified position in this list.
public boolean
add(Object
element to be appended to this list
element
)

Overrides java.util.ArrayList.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this list.
public boolean
addAll(Collection<E>
collection containing elements to be added to this list
c
)

Overrides java.util.ArrayList.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

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.
public boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<E>
collection containing elements to be added to this list
c
)

Overrides java.util.ArrayList.addAll.

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list, starting at the specified position.
protected void
checkCollectionType(Collection<E> 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()

Overrides java.util.ArrayList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Removes all of the elements from this list.
public boolean
equals(Object
the object to be compared for equality with this list
that
)

Overrides java.util.ArrayList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.
public boolean
public MetaClass
getMetaClass()

Implements groovy.lang.GroovyObject.getMetaClass.

Returns the metaclass for a given class.
public Object
getProperty(String
the name of the property of interest
property
)

Overrides default groovy.lang.GroovyObject.getProperty.

Retrieves a property value.
public int
hashCode()

Overrides java.util.ArrayList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this list.
public Object
invokeMethod(String
the name of the method to call
name
,
Object
the arguments to use for the method call
args
)

Overrides default groovy.lang.GroovyObject.invokeMethod.

Invokes the given method.
public int
public Object
remove(int
the index of the element to be removed
index
)

Overrides java.util.ArrayList.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this list.
protected void
removeRange(int
index of first element to be removed
fromIndex
,
int
index after last element to be removed
toIndex
)

Overrides java.util.ArrayList.removeRange.

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
public void
set(Collection<E> collection)

Sets the contents of this sequence to that of the given collection.

public Object
set(int
index of the element to replace
index
,
Object
element to be stored at the specified position
element
)

Overrides java.util.ArrayList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element.
public void
setMetaClass(MetaClass
the new metaclass
metaClass
)

Implements groovy.lang.GroovyObject.setMetaClass.

Allows the MetaClass to be replaced with a derived implementation.
public void
setProperty(String
the name of the property of interest
property
,
Object
the new value for the property
newValue
)

Overrides default groovy.lang.GroovyObject.setProperty.

Sets the given property to the new value.
public Class<T>

Returns:

the type of the elements in the sequence or null if there is no type constraint on this sequence
type
()

Inherited from java.util.ArrayList:
addFirstaddLastclonecontainsensureCapacityforEachgetgetFirstgetLastindexOfisEmptyiteratorlastIndexOflistIteratorlistIteratorremoveremoveAllremoveFirstremoveIfremoveLastreplaceAllretainAllsizesortspliteratorsubListtoArraytoArraytrimToSize

Field Detail

hashCodeback to summary
private int hashCode
metaClassback to summary
private transient MetaClass metaClass
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.ArrayList.serialVersionUID.

typeback to summary
private final Class<T> type

Constructor Detail

Sequenceback to summary
public Sequence()
Sequenceback to summary
public Sequence(Class<T> type)
Sequenceback to summary
public Sequence(Class<T> type, List<E> content)

Method Detail

addback to summary
public void add(int index, Object element)

Overrides java.util.ArrayList.add.

Implements java.util.List.add.

Doc from java.util.ArrayList.add.

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).

Parameters
index:int

index at which the specified element is to be inserted

element:Object

element to be inserted

addback to summary
public boolean add(Object element)

Overrides java.util.ArrayList.add.

Implements java.util.List.add, java.util.Collection.add.

Doc from java.util.ArrayList.add.

Appends the specified element to the end of this list.

Parameters
element:Object

element to be appended to this list

Returns:boolean

true (as specified by Collection#add)

addAllback to summary
public boolean addAll(Collection<E> c)

Overrides java.util.ArrayList.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Doc from java.util.ArrayList.addAll.

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.)

Parameters
c:Collection<E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

addAllback to summary
public boolean addAll(int index, Collection<E> c)

Overrides java.util.ArrayList.addAll.

Implements java.util.List.addAll.

Doc from java.util.ArrayList.addAll.

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.

Parameters
index:int

index at which to insert the first element from the specified collection

c:Collection<E>

collection containing elements to be added to this list

Returns:boolean

true if this list changed as a result of the call

checkCollectionTypeback to summary
protected void checkCollectionType(Collection<E> c)

Checks that each member of the given collection are of the correct type

checkTypeback to summary
protected void checkType(Object object)

Checks that the given object instance is of the correct type otherwise a runtime exception is thrown

clearback to summary
public void clear()

Overrides java.util.ArrayList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Doc from java.util.ArrayList.clear.

Removes all of the elements from this list. The list will be empty after this call returns.

equalsback to summary
public boolean equals(Object that)

Overrides java.util.ArrayList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.ArrayList.equals.

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 Objects.equals(e1, e2).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters
that:Object

Doc from java.util.List.equals.

the object to be compared for equality with this list

Returns:boolean

Doc from java.util.List.equals.

true if the specified object is equal to this list

equalsback to summary
public boolean equals(Sequence that)
getMetaClassback to summary
public MetaClass getMetaClass()

Implements groovy.lang.GroovyObject.getMetaClass.

Doc from groovy.lang.GroovyObject.getMetaClass.

Returns the metaclass for a given class.

Returns:MetaClass

the metaClass of this instance

getPropertyback to summary
public Object getProperty(String property)

Overrides default groovy.lang.GroovyObject.getProperty.

Doc from groovy.lang.GroovyObject.getProperty.

Retrieves a property value.

Parameters
property:String

the name of the property of interest

Returns:Object

the given property

hashCodeback to summary
public int hashCode()

Overrides java.util.ArrayList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.ArrayList.hashCode.

Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:

int hashCode = 1;
    for (E e : list)
        hashCode = 31*hashCode + (e==null ? 0 : e.hashCode());
This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object#hashCode.
Returns:int

Doc from java.util.List.hashCode.

the hash code value for this list

invokeMethodback to summary
public Object invokeMethod(String name, Object args)

Overrides default groovy.lang.GroovyObject.invokeMethod.

Doc from groovy.lang.GroovyObject.invokeMethod.

Invokes the given method.

Parameters
name:String

the name of the method to call

args:Object

the arguments to use for the method call

Returns:Object

the result of invoking the method

minimumSizeback to summary
public int minimumSize()
removeback to summary
public Object remove(int index)

Overrides java.util.ArrayList.remove.

Implements java.util.List.remove.

Doc from java.util.ArrayList.remove.

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Parameters
index:int

the index of the element to be removed

Returns:Object

the element that was removed from the list

removeRangeback to summary
protected void removeRange(int fromIndex, int toIndex)

Overrides java.util.ArrayList.removeRange.

Doc from java.util.ArrayList.removeRange.

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.)

Parameters
fromIndex:int

Doc from java.util.AbstractList.removeRange.

index of first element to be removed

toIndex:int

Doc from java.util.AbstractList.removeRange.

index after last element to be removed

setback to summary
public void set(Collection<E> collection)

Sets the contents of this sequence to that of the given collection.

setback to summary
public Object set(int index, Object element)

Overrides java.util.ArrayList.set.

Implements java.util.List.set.

Doc from java.util.ArrayList.set.

Replaces the element at the specified position in this list with the specified element.

Parameters
index:int

index of the element to replace

element:Object

element to be stored at the specified position

Returns:Object

the element previously at the specified position

setMetaClassback to summary
public void setMetaClass(MetaClass metaClass)

Implements groovy.lang.GroovyObject.setMetaClass.

Doc from groovy.lang.GroovyObject.setMetaClass.

Allows the MetaClass to be replaced with a derived implementation.

Parameters
metaClass:MetaClass

the new metaclass

setPropertyback to summary
public void setProperty(String property, Object newValue)

Overrides default groovy.lang.GroovyObject.setProperty.

Doc from groovy.lang.GroovyObject.setProperty.

Sets the given property to the new value.

Parameters
property:String

the name of the property of interest

newValue:Object

the new value for the property

typeback to summary
public Class<T> type()
Returns:Class<T>

the type of the elements in the sequence or null if there is no type constraint on this sequence