de.esprit.common.util

## Class PowerList<E>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractList<E>
    - - java.util.ArrayList<E>
      - - de.esprit.common.util.PowerList<E>

- All Implemented Interfaces:
    Dumpable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess
  Direct Known Subclasses:
    PathTreeNodeList

      public class PowerList<E>
      extends java.util.ArrayList<E>
      implements Dumpable

  This class extends `ArrayList` with some useful and frequently needed features. If a Comparator is set, then this list will sort it's items using that Comparator. If the unique-flag is set, then uniqueness is enforced, thus the same item cannot be added twice.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class java.util.AbstractList

      `modCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PowerList()`
    `PowerList(boolean isUnique)` Creates a list that enforces uniqueness
    `PowerList(boolean isUnique, java.util.Comparator<E> cmp)`
    `PowerList(java.util.Collection<E> c)`
    `PowerList(java.util.Comparator<E> cmp)`
    `PowerList(E[] array)`
    `PowerList(E[] array, E oneMore)`
    `PowerList(E[] array, E[] someMore)`
    `PowerList(int initialCapacity)`
    `PowerList(int initialCapacity, boolean isUnique, java.util.Comparator<E> cmp)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E o)`
    `boolean` | `addAll(java.util.Collection<? extends E> c)`
    `boolean` | `addAll(E... array)`
    `int` | `addObject(E o)` Tells at what index the object has been inserted.
    `E` | `getByName(java.lang.String key)` Returns the according object by name.
    `E` | `getByName(java.lang.String key, boolean ignoreCase)` Returns the according object by name.
    `java.util.Comparator<E>` | `getComparator()`
    `E` | `getFirst()`
    `E` | `getLast()`
    `boolean` | `isUnique()` Tells whether this list enforces uniqueness
    `boolean` | `replace(E o)` Replaces the object if found in the list.
    `boolean` | `replaceOrAdd(E o)` Replaces the object if found in the list or adds it if it was not found.
    `boolean` | `setAll(java.util.Collection<? extends E> c)`
    `boolean` | `setAll(E... array)`
    `void` | `setComparator(java.util.Comparator<E> cmp)` Creates a list that sorts it's item using the given comparator.
    `E[]` | `toArray(java.lang.Class type)`
    `java.lang.String` | `toDumpString()` Returns a multi-line String that shows the values (name=value) of all important state variables of this object.
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `java.lang.String` | `toString()` Returns a single line String that shows the values of the most important state variables of this object.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.
    `java.lang.String` | `toStringList()`
    `java.lang.String` | `toStringList(java.lang.String separator)`

    - ### Methods inherited from class java.util.ArrayList

      `add, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, set, size, subList, toArray, toArray, trimToSize`

    - ### Methods inherited from class java.util.AbstractList

      `equals, hashCode`

    - ### Methods inherited from class java.util.AbstractCollection

      `containsAll`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `containsAll, equals, hashCode`

- - ### Constructor Detail

    - #### PowerList

          public PowerList()

    - #### PowerList

          public PowerList(int initialCapacity)

    - #### PowerList

          public PowerList(boolean isUnique)

      Creates a list that enforces uniqueness

    - #### PowerList

          public PowerList(boolean isUnique,
                   java.util.Comparator<E> cmp)

    - #### PowerList

          public PowerList(java.util.Comparator<E> cmp)

    - #### PowerList

          public PowerList(java.util.Collection<E> c)

    - #### PowerList

          public PowerList(E[] array)

    - #### PowerList

          public PowerList(E[] array,
                   E oneMore)

    - #### PowerList

          public PowerList(E[] array,
                   E[] someMore)

    - #### PowerList

          public PowerList(int initialCapacity,
                   boolean isUnique,
                   java.util.Comparator<E> cmp)

  - ### Method Detail

    - #### setComparator

          public final void setComparator(java.util.Comparator<E> cmp)

      Creates a list that sorts it's item using the given comparator. The list will be resorted immediately.
      See Also:
        `GenericComparator`

    - #### getComparator

          public final java.util.Comparator<E> getComparator()

    - #### isUnique

          public final boolean isUnique()

      Tells whether this list enforces uniqueness

    - #### setAll

          public final boolean setAll(E... array)

    - #### addAll

          public final boolean addAll(E... array)

    - #### setAll

          public final boolean setAll(java.util.Collection<? extends E> c)

    - #### addAll

          public final boolean addAll(java.util.Collection<? extends E> c)

      Specified by:
        `addAll` in interface `java.util.Collection<E>`
      Specified by:
        `addAll` in interface `java.util.List<E>`
      Overrides:
        `addAll` in class `java.util.ArrayList<E>`

    - #### toStringList

          public final java.lang.String toStringList()

    - #### toStringList

          public final java.lang.String toStringList(java.lang.String separator)

    - #### getByName

          public final E getByName(java.lang.String key)

      Returns the according object by name. Compares the given key with the object's toString method - case insensitive.

    - #### getByName

          public final E getByName(java.lang.String key,
                    boolean ignoreCase)

      Returns the according object by name. Compares the given key with the object's toString method.

    - #### toArray

          public final E[] toArray(java.lang.Class type)

    - #### add

          public final boolean add(E o)

      Specified by:
        `add` in interface `java.util.Collection<E>`
      Specified by:
        `add` in interface `java.util.List<E>`
      Overrides:
        `add` in class `java.util.ArrayList<E>`

    - #### addObject

          public int addObject(E o)

      Tells at what index the object has been inserted. Returns -1 if the insert failed.

    - #### replace

          public final boolean replace(E o)

      Replaces the object if found in the list.
      Returns:
        true if the object was found in the list

    - #### replaceOrAdd

          public final boolean replaceOrAdd(E o)

      Replaces the object if found in the list or adds it if it was not found.
      Returns:
        true if the object was added, false if it was replaced

    - #### getLast

          public final E getLast()

    - #### getFirst

          public final E getFirst()

    - #### toDumpString

          public final java.lang.String toDumpString()

      Description copied from interface: `Dumpable`
      Returns a multi-line String that shows the values (name=value) of all important state variables of this object.
      Specified by:
        `toDumpString` in interface `Dumpable`

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`

    - #### toString

          public final java.lang.String toString()

      Description copied from interface: `Dumpable`
      Returns a single line String that shows the values of the most important state variables of this object. This is intentionally the same toString() method which is already provided by Object per se.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `java.util.AbstractCollection<E>`

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.