org.apache.felix.ipojo.handlers.dependency

## Class ServiceSet

- java.lang.Object
- - org.apache.felix.ipojo.handlers.dependency.ServiceSet

All Implemented Interfaces:
  java.lang.Iterable, java.util.Collection, java.util.Set

    public class ServiceSet
    extends java.lang.Object
    implements java.util.Collection, java.util.Set

Maintains a service object collection. This collection wrap the dependency to be accessible from a `Set`, that can be passed to helper objects (Collaborators).

The `Collection.iterator()` method returns an `Iterator` iterating on a cached copy of available service objects. In the case that there are no available services, the policies act as follows:

- 'null' returns a null iterator
- 'nullable' and default-implementation returns an iterator iterating on one object (the nullable or default-implementation object
- 'empty' returns an empty iterator.

Because of FELIX-4717, this class does not implement List.

Author:
  Felix Project Team

### Constructor Summary

Constructors
Constructor and Description
`ServiceSet(Dependency dep)` Creates a Service Collection.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `add(int index, java.lang.Object obj)` Unsupported method.
`boolean` `add(java.lang.Object o)` Unsupported method.
`boolean` `addAll(java.util.Collection c)` Unsupported method.
`boolean` `addAll(int index, java.util.Collection c)` Unsupported method.
`void` `clear()` Unsupported method.
`boolean` `contains(java.lang.Object o)` Checks if the wrapped dependency has always access to the given service object.The method allows knowing if the provider returning the service object has left.
`boolean` `containsAll(java.util.Collection c)` Checks if the wrapped dependencies has always access to the given service objects.The method allows knowing if providers returning the service objects have left.
`java.lang.Object` `get(int index)` Gets the object stored at the given index.
`int` `indexOf(java.lang.Object o)` Gets the index of the given object in the current collection.
`boolean` `isEmpty()` Checks if at least one provider matching with the dependency is available.
`java.util.Iterator` `iterator()` Gets an iterator on the current list of available service objects.
`int` `lastIndexOf(java.lang.Object o)` Gets the last index of the given object in the current collection.
`java.util.ListIterator` `listIterator()` Gets a list iterator on the current list of available service objects.
`java.util.ListIterator` `listIterator(int index)` Unsupported Method.
`java.lang.Object` `remove(int index)` Unsupported method.
`boolean` `remove(java.lang.Object o)` Unsupported method.
`boolean` `removeAll(java.util.Collection c)` Unsupported method.
`boolean` `retainAll(java.util.Collection c)` Unsupported method.
`java.lang.Object` `set(int arg0, java.lang.Object arg1)` Unsupported Method.
`int` `size()` Gets the number of available providers.
`java.util.List` `subList(int fromIndex, int toIndex)` Returns a sublist from the current list.
`java.lang.Object[]` `toArray()` Returns an array containing available service objects.
`java.lang.Object[]` `toArray(java.lang.Object[] a)` Returns an array containing available service objects.

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

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

### Methods inherited from interface java.util.Set

`equals, hashCode, spliterator`

### Methods inherited from interface java.util.Collection

`parallelStream, removeIf, stream`

### Methods inherited from interface java.lang.Iterable

`forEach`

### Constructor Detail

#### ServiceSet

    public ServiceSet(Dependency dep)

Creates a Service Collection.

Parameters:
  `dep` - the wrapped dependency

### Method Detail

#### add

    public boolean add(java.lang.Object o)

Unsupported method.

Specified by:
  `add` in interface `java.util.Collection`
Specified by:
  `add` in interface `java.util.Set`
Parameters:
  `o` - an object
Returns:
  N/A
See Also:
  `Collection.add(Object)`

#### addAll

    public boolean addAll(java.util.Collection c)

Unsupported method.

Specified by:
  `addAll` in interface `java.util.Collection`
Specified by:
  `addAll` in interface `java.util.Set`
Parameters:
  `c` - an object
Returns:
  N/A
See Also:
  `Collection.addAll(java.util.Collection)`

#### add

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

Unsupported method.

Parameters:
  `index` - an index
  `obj` - an object
See Also:
  `List.add(int, Object)`

#### addAll

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

Unsupported method.

Parameters:
  `index` - an index
  `c` - an object
Returns:
  N/A
See Also:
  `List.addAll(int, java.util.Collection)`

#### clear

    public void clear()

Unsupported method.

Specified by:
  `clear` in interface `java.util.Collection`
Specified by:
  `clear` in interface `java.util.Set`
See Also:
  `Collection.clear()`

#### contains

    public boolean contains(java.lang.Object o)

Checks if the wrapped dependency has always access to the given service object.The method allows knowing if the provider returning the service object has left.

Specified by:
  `contains` in interface `java.util.Collection`
Specified by:
  `contains` in interface `java.util.Set`
Parameters:
  `o` - the service object
Returns:
  `true` if the object is still available, `false` otherwise.
See Also:
  `Collection.contains(Object)`

#### containsAll

    public boolean containsAll(java.util.Collection c)

Checks if the wrapped dependencies has always access to the given service objects.The method allows knowing if providers returning the service objects have left.

Specified by:
  `containsAll` in interface `java.util.Collection`
Specified by:
  `containsAll` in interface `java.util.Set`
Parameters:
  `c` - the set of service object
Returns:
  `true` if the objects are still available, `false` otherwise.
See Also:
  `Collection.contains(Object)`

#### isEmpty

    public boolean isEmpty()

Checks if at least one provider matching with the dependency is available.

Specified by:
  `isEmpty` in interface `java.util.Collection`
Specified by:
  `isEmpty` in interface `java.util.Set`
Returns:
  `true` if one provider or more satisfying the dependency are available. Otherwise, returns `false`
See Also:
  `Collection.isEmpty()`

#### iterator

    public java.util.Iterator iterator()

Gets an iterator on the current list of available service objects. The returned iterator iterates on a cached copy of the service objects.

Specified by:
  `iterator` in interface `java.lang.Iterable`
Specified by:
  `iterator` in interface `java.util.Collection`
Specified by:
  `iterator` in interface `java.util.Set`
Returns:
  a iterator giving access to service objects.
See Also:
  `Collection.iterator()`

#### remove

    public boolean remove(java.lang.Object o)

Unsupported method.

Specified by:
  `remove` in interface `java.util.Collection`
Specified by:
  `remove` in interface `java.util.Set`
Parameters:
  `o` - a object
Returns:
  N/A
See Also:
  `Collection.remove(Object)`

#### remove

    public java.lang.Object remove(int index)

Unsupported method.

Parameters:
  `index` - the index
Returns:
  N/A
See Also:
  `Collection.remove(Object)`

#### removeAll

    public boolean removeAll(java.util.Collection c)

Unsupported method.

Specified by:
  `removeAll` in interface `java.util.Collection`
Specified by:
  `removeAll` in interface `java.util.Set`
Parameters:
  `c` - a set of objects
Returns:
  N/A
See Also:
  `Collection.removeAll(java.util.Collection)`

#### retainAll

    public boolean retainAll(java.util.Collection c)

Unsupported method.

Specified by:
  `retainAll` in interface `java.util.Collection`
Specified by:
  `retainAll` in interface `java.util.Set`
Parameters:
  `c` - a set of objects
Returns:
  N/A
See Also:
  `Collection.retainAll(java.util.Collection)`

#### size

    public int size()

Gets the number of available providers.

Specified by:
  `size` in interface `java.util.Collection`
Specified by:
  `size` in interface `java.util.Set`
Returns:
  the number of matching service providers.
See Also:
  `Collection.size()`

#### toArray

    public java.lang.Object[] toArray()

Returns an array containing available service objects. This method executed on timeout policies if no matching providers when the timeout is reached.

Specified by:
  `toArray` in interface `java.util.Collection`
Specified by:
  `toArray` in interface `java.util.Set`
Returns:
  a array containing available service objects.
See Also:
  `Collection.toArray()`

#### toArray

    public java.lang.Object[] toArray(java.lang.Object[] a)

Returns an array containing available service objects. This method executed on timeout policies if no matching providers when the timeout is reached.

Specified by:
  `toArray` in interface `java.util.Collection`
Specified by:
  `toArray` in interface `java.util.Set`
Parameters:
  `a` - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
  a array containing available service objects.
See Also:
  `Collection.toArray(Object[])`

#### get

    public java.lang.Object get(int index)

Gets the object stored at the given index.

Parameters:
  `index` - the index
Returns:
  the service object
See Also:
  `List.get(int)`

#### indexOf

    public int indexOf(java.lang.Object o)

Gets the index of the given object in the current collection.

Parameters:
  `o` - the object
Returns:
  the index of the object of `-1` if not found.
See Also:
  `List.indexOf(Object)`

#### lastIndexOf

    public int lastIndexOf(java.lang.Object o)

Gets the last index of the given object in the current collection.

Parameters:
  `o` - the object
Returns:
  the index of the object of `-1` if not found.
See Also:
  `List.lastIndexOf(Object)`

#### listIterator

    public java.util.ListIterator listIterator()

Gets a list iterator on the current list of available service objects. The returned iterator iterates on a cached copy of the service objects.

Returns:
  a iterator giving access to service objects.
See Also:
  `List.listIterator()`

#### listIterator

    public java.util.ListIterator listIterator(int index)

Unsupported Method.

Parameters:
  `index` - an index
Returns:
  N/A
See Also:
  `List.listIterator(int)`

#### set

    public java.lang.Object set(int arg0,
                                java.lang.Object arg1)

Unsupported Method.

Parameters:
  `arg0` - an index
  `arg1` - an object
Returns:
  N/A
See Also:
  `List.set(int, Object)`

#### subList

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

Returns a sublist from the current list.

Parameters:
  `fromIndex` - the index of the list beginning
  `toIndex` - the index of the list end
Returns:
  the sub-list
See Also:
  `List.subList(int, int)`