Groovy Documentation

## org.codehaus.groovy.grails.web.binding
[Java] Class ListOrderedSet

    java.lang.Object
      org.apache.commons.collections.set.AbstractSerializableSetDecorator
          org.codehaus.groovy.grails.web.binding.ListOrderedSet

All Implemented Interfaces:
  java.util.Set

    public class ListOrderedSet
    extends AbstractSerializableSetDecorator

Forked from Apache Commons Collections' implementation of ListOrderedSet. This one actually implements the List interface. Yes we are away of the warnings in the javadoc about problems with incompatibilities between the List and Set interfaces, however this class is designed to used internally only for data binding and not by end users.

Authors:
  Stephen Colebourne
  Henning P. Schmiedehausen
  Graeme Rocher

Field Summary
`protected java.util.List` | `setOrder` Internal list to hold the sequence of objects

Constructor Summary
`ListOrderedSet()` Constructs a new empty ListOrderedSet using a HashSet and an ArrayList internally.
`protected ListOrderedSet(java.util.Set set)` Constructor that wraps (not copies).
`protected ListOrderedSet(java.util.Set set, java.util.List list)` Constructor that wraps (not copies) the Set and specifies the list to use.

Method Summary
`boolean` | `add(java.lang.Object object)`
`void` | `add(int index, java.lang.Object object)`
`boolean` | `addAll(java.util.Collection coll)`
`boolean` | `addAll(int index, java.util.Collection coll)`
`java.util.List` | `asList()` Gets an unmodifiable view of the order of the Set.
`void` | `clear()`
`static ListOrderedSet` | `decorate(java.util.Set set)` Factory method to create an ordered set.
`static ListOrderedSet` | `decorate(java.util.List list)` Factory method to create an ordered set using the supplied list to retain order.
`java.lang.Object` | `get(int index)`
`int` | `indexOf(java.lang.Object object)`
`java.util.Iterator` | `iterator()`
`int` | `lastIndexOf(java.lang.Object o)`
`java.util.ListIterator` | `listIterator()`
`java.util.ListIterator` | `listIterator(int index)`
`boolean` | `remove(java.lang.Object object)`
`java.lang.Object` | `remove(int index)`
`boolean` | `removeAll(java.util.Collection coll)`
`boolean` | `retainAll(java.util.Collection coll)`
`java.lang.Object` | `set(int index, java.lang.Object element)`
`java.util.List` | `subList(int fromIndex, int toIndex)`
`Object[]` | `toArray()`
`Object[]` | `toArray(Object[] a)`
`java.lang.String` | `toString()` Uses the underlying List's toString so that order is achieved.

Field Detail

### setOrder

    protected final java.util.List setOrder

  Internal list to hold the sequence of objects

Constructor Detail

### ListOrderedSet

    public ListOrderedSet()

  Constructs a new empty ListOrderedSet using a HashSet and an ArrayList internally.
  Since:
    Commons Collections 3.1

### ListOrderedSet

    protected ListOrderedSet(java.util.Set set)

  Constructor that wraps (not copies).
  throws:
    IllegalArgumentException if set is null
  Parameters:
    `set` - the set to decorate, must not be null

### ListOrderedSet

    protected ListOrderedSet(java.util.Set set, java.util.List list)

  Constructor that wraps (not copies) the Set and specifies the list to use. The set and list must both be correctly initialised to the same elements.
  throws:
    IllegalArgumentException if set or list is null
  Parameters:
    `set` - the set to decorate, must not be null
    `list` - the list to decorate, must not be null

Method Detail

### add

    public boolean add(java.lang.Object object)

### add

    public void add(int index, java.lang.Object object)

### addAll

    public boolean addAll(java.util.Collection coll)

### addAll

    public boolean addAll(int index, java.util.Collection coll)

### asList

    public java.util.List asList()

  Gets an unmodifiable view of the order of the Set.
  Returns:
    an unmodifiable list view

### clear

    public void clear()

### decorate

    public static ListOrderedSet decorate(java.util.Set set)

  Factory method to create an ordered set. An ArrayList is used to retain order.
  throws:
    IllegalArgumentException if set is null
  Parameters:
    `set` - the set to decorate, must not be null

### decorate

    public static ListOrderedSet decorate(java.util.List list)

  Factory method to create an ordered set using the supplied list to retain order. A HashSet is used for the set behaviour.
  throws:
    IllegalArgumentException if list is null
  Parameters:
    `list` - the list to decorate, must not be null

### get

    public java.lang.Object get(int index)

### indexOf

    public int indexOf(java.lang.Object object)

### iterator

    public java.util.Iterator iterator()

### lastIndexOf

    public int lastIndexOf(java.lang.Object o)

### listIterator

    public java.util.ListIterator listIterator()

### listIterator

    public java.util.ListIterator listIterator(int index)

### remove

    public boolean remove(java.lang.Object object)

### remove

    public java.lang.Object remove(int index)

### removeAll

    public boolean removeAll(java.util.Collection coll)

### retainAll

    public boolean retainAll(java.util.Collection coll)

### set

    public java.lang.Object set(int index, java.lang.Object element)

### subList

    public java.util.List subList(int fromIndex, int toIndex)

### toArray

    public Object[] toArray()

### toArray

    public Object[] toArray(Object[] a)

### toString

    public java.lang.String toString()

  Uses the underlying List's toString so that order is achieved. This means that the decorated Set's toString is not used, so any custom toStrings will be ignored.

Groovy Documentation