Class ServiceList

All Implemented Interfaces:
Iterable<Service>, Collection<Service>, List<Service>

public final class ServiceList extends WrapperList<Service>
Modifiable list of services.
Author:
Jerome Louvel
  • Constructor Details

    • ServiceList

      public ServiceList(Context context)
      Constructor.
      Parameters:
      context - The context.
  • Method Details

    • add

      public void add(int index, Service service)
      Description copied from class: WrapperList
      Inserts the specified element at the specified position in this list.
      Specified by:
      add in interface List<Service>
      Overrides:
      add in class WrapperList<Service>
      Parameters:
      index - The insertion position.
      service - The element to insert.
    • add

      public boolean add(Service service)
      Description copied from class: WrapperList
      Adds a element at the end of the list.
      Specified by:
      add in interface Collection<Service>
      Specified by:
      add in interface List<Service>
      Overrides:
      add in class WrapperList<Service>
      Returns:
      True (as per the general contract of the Collection.add method).
    • addAll

      public boolean addAll(Collection<? extends Service> services)
      Description copied from class: WrapperList
      Appends all of the elements in the specified collection to the end of this list.
      Specified by:
      addAll in interface Collection<Service>
      Specified by:
      addAll in interface List<Service>
      Overrides:
      addAll in class WrapperList<Service>
      Parameters:
      services - The collection of elements to append.
    • addAll

      public boolean addAll(int index, Collection<? extends Service> services)
      Description copied from class: WrapperList
      Inserts all of the elements in the specified collection into this list at the specified position.
      Specified by:
      addAll in interface List<Service>
      Overrides:
      addAll in class WrapperList<Service>
      Parameters:
      index - The insertion position.
      services - The collection of elements to insert.
    • get

      public <T extends Service> T get(Class<T> clazz)
      Returns a service matching a given service class.
      Type Parameters:
      T - The service type.
      Parameters:
      clazz - The service class to match.
      Returns:
      The matched service instance.
    • getContext

      public Context getContext()
      Returns the context.
      Returns:
      The context.
    • set

      public void set(List<Service> services)
      Sets the list of services.
      Parameters:
      services - The list of services.
    • set

      public void set(Service newService)
      Replaces or adds a service. The replacement is based on the service class.
      Parameters:
      newService - The new service to set.
    • setContext

      public void setContext(Context context)
      Sets the context. By default, it also updates the context of already registered services.
      Parameters:
      context - The context.
    • start

      public void start() throws Exception
      Starts each service.
      Throws:
      Exception
    • stop

      public void stop() throws Exception
      Stops each service.
      Throws:
      Exception