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, 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`

  - ### Field Summary

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

      `USE_LABEL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SetContainer(Class<E> componentType)`
    `SetContainer(Class<E> componentType, Set<E> set)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addAllElements(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).
    `Class<E>` | `getComponentType()`
    `E[]` | `getElements()`
    `IContainer.Persistence<E>` | `getPersistence()`
    `protected Set<E>` | `getSet()`
    `boolean` | `isEmpty()`
    `boolean` | `isSavedWhenModified()`
    `void` | `load()`
    `boolean` | `removeAllElements(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, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, 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(Class<E> componentType)

    - #### SetContainer

          public SetContainer(Class<E> componentType,
                              Set<E> set)

  - ### Method Detail

    - #### getComponentType

          public final 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(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(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 Exception

      Overrides:
        `doActivate` in class `Lifecycle`
      Throws:
        `Exception`

    - #### doDeactivate

          protected void doDeactivate()
                               throws Exception

      Overrides:
        `doDeactivate` in class `Lifecycle`
      Throws:
        `Exception`

    - #### getSet

          protected 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

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html