Package: groovy.lang

## [Java] Class Sequence

- groovy.lang.Sequence

- All Implemented Interfaces and Traits:
    GroovyObject

      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.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Sequence()` Creates a sequence with no type restriction.
    `Sequence(Class type)` Creates a sequence constrained to the supplied type.
    `Sequence(Class type, List content)` Creates a sequence initialized with the supplied content.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `add(int index, Object element)` {@inheritDoc}
    `` | `public boolean` | `add(Object element)` {@inheritDoc}
    `` | `public boolean` | `addAll(Collection c)` {@inheritDoc}
    `` | `public boolean` | `addAll(int index, Collection c)` {@inheritDoc}
    `` | `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()` {@inheritDoc}
    `` | `public boolean` | `equals(Object that)` {@inheritDoc}
    `` | `public boolean` | `equals(Sequence that)` Compares this sequence with another sequence using Groovy equality.
    `` | `public MetaClass` | `getMetaClass()` Returns the metaclass for a given class. Returns: the metaClass of this instance
    `` | `public Object` | `getProperty(String property)` Retrieves a property value. Parameters: `propertyName` - the name of the property of interest Returns: the given property
    `` | `public int` | `hashCode()` {@inheritDoc}
    `` | `public Object` | `invokeMethod(String name, Object args)` Invokes the given method. Parameters: `name` - the name of the method to call `args` - the arguments to use for the method call Returns: the result of invoking the method
    `` | `public int` | `minimumSize()` Returns the minimum allowed size for this sequence.
    `` | `public Object` | `remove(int index)` {@inheritDoc}
    `` | `protected void` | `removeRange(int fromIndex, int toIndex)` {@inheritDoc}
    `` | `public void` | `set(Collection collection)` Sets the contents of this sequence to that of the given collection.
    `` | `public Object` | `set(int index, Object element)` {@inheritDoc}
    `` | `public void` | `setMetaClass(MetaClass metaClass)` Allows the MetaClass to be replaced with a derived implementation. Parameters: `metaClass` - the new metaclass
    `` | `public void` | `setProperty(String property, Object newValue)` Sets the given property to the new value. Parameters: `propertyName` - the name of the property of interest `newValue` - the new value for the property
    `` | `public Class` | `type()` Returns: the type of the elements in the sequence or null if there is no type constraint on this sequence

  - ### Inherited Methods Summary

    Inherited Methods
    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`

- - ### Constructor Detail

    - #### public Sequence()

      Creates a sequence with no type restriction.

    - #### public Sequence(Class type)

      Creates a sequence constrained to the supplied type.

      Parameters:
        `type` - the allowed element type

    - #### public Sequence(Class type, List content)

      Creates a sequence initialized with the supplied content.

      Parameters:
        `type` - the allowed element type
        `content` - the initial content

  - ### Method Detail

    - #### public void add(int index, Object element)

      {@inheritDoc}

    - #### public boolean add(Object element)

      {@inheritDoc}

    - #### public boolean addAll(Collection c)

      {@inheritDoc}

    - #### public boolean addAll(int index, Collection c)

      {@inheritDoc}

    - #### 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()

      {@inheritDoc}

    - #### public boolean equals(Object that)

      {@inheritDoc}

    - #### public boolean equals(Sequence that)

      Compares this sequence with another sequence using Groovy equality.

      Parameters:
        `that` - the other sequence
      Returns:
        `true` if the sequences are equal

    - #### public MetaClass getMetaClass()

      Returns the metaclass for a given class.

      Returns:
        the metaClass of this instance

    - #### public Object getProperty(String property)

      Retrieves a property value.

      Parameters:
        `propertyName` - the name of the property of interest
      Returns:
        the given property

    - #### public int hashCode()

      {@inheritDoc}

    - #### public Object invokeMethod(String name, Object args)

      Invokes the given method.

      Parameters:
        `name` - the name of the method to call
        `args` - the arguments to use for the method call
      Returns:
        the result of invoking the method

    - #### public int minimumSize()

      Returns the minimum allowed size for this sequence.

      Returns:
        the minimum size

    - #### public Object remove(int index)

      {@inheritDoc}

    - #### protected void removeRange(int fromIndex, int toIndex)

      {@inheritDoc}

    - #### public void set(Collection collection)

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

    - #### public Object set(int index, Object element)

      {@inheritDoc}

    - #### public void setMetaClass(MetaClass metaClass)

      Allows the MetaClass to be replaced with a derived implementation.

      Parameters:
        `metaClass` - the new metaclass

    - #### public void setProperty(String property, Object newValue)

      Sets the given property to the new value.

      Parameters:
        `propertyName` - the name of the property of interest
        `newValue` - the new value for the property

    - #### public Class type()

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