org.qi4j.api.service.qualifier

## Class ServiceQualifier

- java.lang.Object
- - org.qi4j.api.service.qualifier.ServiceQualifier

-     public abstract class ServiceQualifier
      extends Object

  This class helps you select a particular service from a list.

  Provide a Selector which does the actual selection from the list. A common case is to select based on identity of the service, which you can do this way:

       new ServiceQualifier<MyService>(services, ServiceQualifier.withId("someId"))

  Many selectors can be combined by using firstOf. Example:

       new ServiceQualifier<MyService>(services, firstOf(withTags("sometag"), firstActive(), first()))

  This will pick a service that has the tag "sometag", or if none is found take the first active one. If no service is active, then the first service will be picked.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceQualifier()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> T` | `firstService(Specification<ServiceReference<?>> qualifier, Iterable<ServiceReference<T>> services)`
    `static Specification<ServiceReference<?>>` | `whereActive()`
    `static Specification<ServiceReference<?>>` | `whereAvailable()`
    `static Specification<ServiceReference<?>>` | `whereMetaInfoIs(Object metaInfo)`
    `static Specification<ServiceReference<?>>` | `withId(String anId)`
    `static Specification<ServiceReference<?>>` | `withTags(String... tags)`

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

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

- - ### Constructor Detail

    - #### ServiceQualifier

          public ServiceQualifier()

  - ### Method Detail

    - #### firstService

          public static <T> T firstService(Specification<ServiceReference<?>> qualifier,
                           Iterable<ServiceReference<T>> services)

    - #### withId

          public static Specification<ServiceReference<?>> withId(String anId)

    - #### whereMetaInfoIs

          public static Specification<ServiceReference<?>> whereMetaInfoIs(Object metaInfo)

    - #### whereActive

          public static Specification<ServiceReference<?>> whereActive()

    - #### whereAvailable

          public static Specification<ServiceReference<?>> whereAvailable()

    - #### withTags

          public static Specification<ServiceReference<?>> withTags(String... tags)