Package org.apache.sling.api.adapter
Interface AdapterManager
@ProviderType
public interface AdapterManager
The
AdapterManager
defines the service interface for a manager
for object adaption. The adapter manager coordinates the registered
AdapterFactory
services on behalf of clients wishing to adapt objects
to other types. One such client is the SlingAdaptable
class, which
uses the implementation of this bundle to adapt "itself".
Clients may either extend from the SlingAdaptable
class or access the
AdapterManager
service from the OSGi service registry to adapt
objects to other types.
This interface is not intended to be implemented by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name under which this service is registered with the OSGi service registry. -
Method Summary
Modifier and TypeMethodDescription<AdapterType>
AdapterTypegetAdapter
(@NotNull Object adaptable, @NotNull Class<AdapterType> type) Returns an adapter object of the requestedAdapterType
for the givenadaptable
object.
-
Field Details
-
SERVICE_NAME
The name under which this service is registered with the OSGi service registry.- See Also:
-
-
Method Details
-
getAdapter
@Nullable <AdapterType> AdapterType getAdapter(@NotNull @NotNull Object adaptable, @NotNull @NotNull Class<AdapterType> type) Returns an adapter object of the requestedAdapterType
for the givenadaptable
object.The
adaptable
object may be any non-null
object and is not required to implement theAdaptable
interface.- Type Parameters:
AdapterType
- The generic type of the adapter (target) type.- Parameters:
adaptable
- The object to adapt to the adapter type.type
- The type to which the object is to be adapted.- Returns:
- The adapted object or
null
if no factory exists to adapt theadaptable
to theAdapterType
or if theadaptable
cannot be adapted for any other reason.
-