Interface ServiceProvider

  • All Known Subinterfaces:
    Collection
    All Known Implementing Classes:
    ServiceProviderCache

    public interface ServiceProvider
    The ServiceProvider interface access to the Service implementation instances and is able to query for implemented ones.
    Since:
    2.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      <S extends Service>
      java.util.Optional<S>
      findService​(java.lang.Class<S> serviceType)
      Returns optional Service instance for the requested serviceType.
      default <S extends Service>
      S
      getService​(java.lang.Class<S> serviceType)
      Returns a Service instance for the requested serviceType.
      <S extends Service>
      boolean
      hasService​(java.lang.Class<S> serviceType)
      Checks if a service of the given serviceType is available.
    • Method Detail

      • hasService

        <S extends Service> boolean hasService​(java.lang.Class<S> serviceType)
        Checks if a service of the given serviceType is available. This method will return false in case of the specified service can not be provided for any reason.
        Returns:
        true if the given service type is supported, false otherwise
        Since:
        2.0
      • findService

        <S extends Service> java.util.Optional<S> findService​(java.lang.Class<S> serviceType)
        Returns optional Service instance for the requested serviceType. If no Service exists or can be provided an empty optional is returned.
        Type Parameters:
        S - the type of service
        Parameters:
        serviceType - the type of service to return
        Returns:
        a optional instance of the given service type
        Since:
        2.0