Package org.eclipse.net4j.util.container

## Class SetContainer<E>

- java.lang.Object
- - org.eclipse.net4j.util.event.Notifier
  - - org.eclipse.net4j.util.lifecycle.Lifecycle
    - - org.eclipse.net4j.util.lifecycle.ShareableLifecycle
      - - org.eclipse.net4j.util.container.Container<E>
        - - org.eclipse.net4j.util.container.SetContainer<E>

- All Implemented Interfaces:
    `IContainer<E>`, `IContainer.Modifiable<E>`, `IContainer.Persistable<E>`, `INotifier`, `INotifier.INotifier2`, `IDeactivateable`, `ILifecycle`, `ILifecycle.DeferrableActivation`

      public class SetContainer<E>
      extends Container<E>
      implements IContainer.Modifiable<E>, IContainer.Persistable<E>

  An implementation of a `container` that stores its `elements` in a `set`.
  Since:
    3.2
  Author:
    Eike Stepper
  See Also:
    `IContainerSet`, `IContainerSortedSet`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.container.IContainer

      `IContainer.Modifiable<E>, IContainer.Persistable<E>, IContainer.Persistence<E>`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle

      `ILifecycle.DeferrableActivation`

    - ### Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier

      `INotifier.INotifier2`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SetContainer​(java.lang.Class<E> componentType)` |
    `SetContainer​(java.lang.Class<E> componentType, java.util.Set<E> set)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `addAllElements​(java.util.Collection<E> elements)` |
    `boolean` | `addElement​(E element)` |
    `void` | `clear()` |
    `protected void` | `containerModified()` | Called outside synchronized(this).
    `protected void` | `doActivate()` |
    `protected void` | `doDeactivate()` |
    `protected void` | `elementAdded​(E element)` | Called inside synchronized(this).
    `protected void` | `elementRemoved​(E element)` | Called inside synchronized(this).
    `java.lang.Class<E>` | `getComponentType()` |
    `E[]` | `getElements()` |
    `IContainer.Persistence<E>` | `getPersistence()` |
    `protected java.util.Set<E>` | `getSet()` |
    `boolean` | `isEmpty()` |
    `boolean` | `isSavedWhenModified()` |
    `void` | `load()` |
    `boolean` | `removeAllElements​(java.util.Collection<E> elements)` |
    `boolean` | `removeElement​(E element)` |
    `void` | `save()` |
    `void` | `setPersistence​(IContainer.Persistence<E> persistence)` |
    `protected E[]` | `sortElements​(E[] array)` | Called outside synchronized(this).
    `protected boolean` | `validateElement​(E element)` | Called outside synchronized(this).

    - ### Methods inherited from class org.eclipse.net4j.util.container.Container

      `fireContainerEvent, fireContainerEvent, fireContainerEvent, fireElementAddedEvent, fireElementRemovedEvent, fireElementsAddedEvent, fireElementsRemovedEvent, fireEvent, newContainerEvent, newContainerEvent`

    - ### Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle

      `activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString`

    - ### Methods inherited from class org.eclipse.net4j.util.event.Notifier

      `addListener, addUniqueListener, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.net4j.util.event.INotifier

      `addListener, getListeners, hasListeners, removeListener`

- - ### Constructor Detail

    - #### SetContainer

          public SetContainer​(java.lang.Class<E> componentType)

    - #### SetContainer

          public SetContainer​(java.lang.Class<E> componentType,
                              java.util.Set<E> set)

  - ### Method Detail

    - #### getComponentType

          public final java.lang.Class<E> getComponentType()

    - #### getPersistence

          public final IContainer.Persistence<E> getPersistence()

      Specified by:
        `getPersistence` in interface `IContainer.Persistable<E>`
      Since:
        3.5

    - #### setPersistence

          public final void setPersistence​(IContainer.Persistence<E> persistence)

      Specified by:
        `setPersistence` in interface `IContainer.Persistable<E>`
      Since:
        3.5

    - #### isSavedWhenModified

          public boolean isSavedWhenModified()

      Since:
        3.5

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `IContainer<E>`
      Overrides:
        `isEmpty` in class `Container<E>`

    - #### getElements

          public E[] getElements()

      Specified by:
        `getElements` in interface `IContainer<E>`

    - #### addElement

          public boolean addElement​(E element)

      Specified by:
        `addElement` in interface `IContainer.Modifiable<E>`

    - #### addAllElements

          public boolean addAllElements​(java.util.Collection<E> elements)

      Specified by:
        `addAllElements` in interface `IContainer.Modifiable<E>`
      Since:
        3.5

    - #### removeElement

          public boolean removeElement​(E element)

      Specified by:
        `removeElement` in interface `IContainer.Modifiable<E>`

    - #### removeAllElements

          public boolean removeAllElements​(java.util.Collection<E> elements)

      Specified by:
        `removeAllElements` in interface `IContainer.Modifiable<E>`
      Since:
        3.5

    - #### clear

          public void clear()

    - #### load

          public void load()
                    throws IORuntimeException

      Specified by:
        `load` in interface `IContainer.Persistable<E>`
      Throws:
        `IORuntimeException`
      Since:
        3.5

    - #### save

          public void save()
                    throws IORuntimeException

      Specified by:
        `save` in interface `IContainer.Persistable<E>`
      Throws:
        `IORuntimeException`
      Since:
        3.5

    - #### doActivate

          protected void doActivate()
                             throws java.lang.Exception

      Overrides:
        `doActivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### doDeactivate

          protected void doDeactivate()
                               throws java.lang.Exception

      Overrides:
        `doDeactivate` in class `Lifecycle`
      Throws:
        `java.lang.Exception`

    - #### getSet

          protected java.util.Set<E> getSet()

    - #### sortElements

          protected E[] sortElements​(E[] array)

      Called outside synchronized(this).

    - #### validateElement

          protected boolean validateElement​(E element)

      Called outside synchronized(this).

    - #### containerModified

          protected void containerModified()

      Called outside synchronized(this).
      Since:
        3.5

    - #### elementAdded

          protected void elementAdded​(E element)

      Called inside synchronized(this).
      Since:
        3.5

    - #### elementRemoved

          protected void elementRemoved​(E element)

      Called inside synchronized(this).
      Since:
        3.5