Stay organized with collections
Save and categorize content based on your preferences.
Provider
interface Provider<S : Any!> : Supplier<S>
Represents a service provider located by ServiceLoader
.
When using a loader's stream()
method then the elements are of type Provider
. This allows processing to select or filter on the provider class without instantiating the provider.
Summary
Public methods |
abstract S |
Returns an instance of the provider.
|
abstract Class<out S>! |
Returns the provider type.
|
Public methods
get
abstract fun get(): S
Returns an instance of the provider.
Return |
S |
An instance of the provider. |
Exceptions |
java.util.ServiceConfigurationError |
If the service provider cannot be instantiated, or in the case of a provider factory, the public static "provider() " method returns null or throws an error or exception. The ServiceConfigurationError will carry an appropriate cause where possible. |
type
abstract fun type(): Class<out S>!
Returns the provider type. There is no guarantee that this type is accessible or that it has a public no-args constructor. The get()
method should be used to obtain the provider instance.
When a module declares that the provider class is created by a provider factory then this method returns the return type of its public static "provider()
" method.
Return |
Class<out S>! |
The provider type |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ServiceLoader.Provider\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nProvider\n========\n\n```\ninterface Provider\u003cS : Any!\u003e : Supplier\u003cS\u003e\n```\n\n|---------------------------------------|\n| [java.util.ServiceLoader.Provider](#) |\n\nRepresents a service provider located by `ServiceLoader`.\n\nWhen using a loader's [stream()](/reference/kotlin/java/util/ServiceLoader#stream()) method then the elements are of type `Provider`. This allows processing to select or filter on the provider class without instantiating the provider.\n\nSummary\n-------\n\n| Public methods ||\n|-------------------------------------------------|--------------------------------------------------------|\n| abstract S | [get](#get())`()` Returns an instance of the provider. |\n| abstract [Class](../lang/Class.html#)\\\u003cout S\\\u003e! | [type](#type())`()` Returns the provider type. |\n\nPublic methods\n--------------\n\n### get\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun get(): S\n```\n\nReturns an instance of the provider.\n\n| Return ||\n|---|------------------------------|\n| S | An instance of the provider. |\n\n| Exceptions ||\n|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.util.ServiceConfigurationError` | If the service provider cannot be instantiated, or in the case of a provider factory, the public static \"`provider()`\" method returns `null` or throws an error or exception. The `ServiceConfigurationError` will carry an appropriate cause where possible. |\n\n### type\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun type(): Class\u003cout S\u003e!\n```\n\nReturns the provider type. There is no guarantee that this type is accessible or that it has a public no-args constructor. The [get()](#get()) method should be used to obtain the provider instance.\n\nWhen a module declares that the provider class is created by a provider factory then this method returns the return type of its public static \"`provider()`\" method.\n\n| Return ||\n|----------------------------------------|-------------------|\n| [Class](../lang/Class.html#)\u003cout` `S\u003e! | The provider type |"]]