Class ServiceList

  • All Implemented Interfaces:
    java.lang.Iterable<Service>, java.util.Collection<Service>, java.util.List<Service>

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

      • ServiceList

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

      • 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 java.util.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 java.util.Collection<Service>
        Specified by:
        add in interface java.util.List<Service>
        Overrides:
        add in class WrapperList<Service>
        Returns:
        True (as per the general contract of the Collection.add method).
      • addAll

        public boolean addAll​(java.util.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 java.util.Collection<Service>
        Specified by:
        addAll in interface java.util.List<Service>
        Overrides:
        addAll in class WrapperList<Service>
        Parameters:
        services - The collection of elements to append.
      • addAll

        public boolean addAll​(int index,
                              java.util.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 java.util.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​(java.lang.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​(java.util.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 java.lang.Exception
        Starts each service.
        Throws:
        java.lang.Exception
      • stop

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