Package org.apache.sling.api.adapter
Interface Adaptable
-
- All Known Subinterfaces:
Resource,ResourceResolver,SlingHttpServletRequest,SlingHttpServletResponse,SlingHttpServletResponseResult
- All Known Implementing Classes:
AbstractResource,NonExistingResource,ResourceResolverWrapper,ResourceWrapper,SlingAdaptable,SlingHttpServletRequestWrapper,SlingHttpServletResponseWrapper,SyntheticResource
@ConsumerType public interface AdaptableTheAdaptableinterface identifies objects which can be adapted to other types or representations of the same object. For example a JCR Node basedResourcecan adapt to the underlying JCR Node or a file based resource could adapt to the underlyingjava.io.File.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <AdapterType>
AdapterTypeadaptTo(@NotNull Class<AdapterType> type)Adapts the adaptable to another type.
-
-
-
Method Detail
-
adaptTo
@Nullable <AdapterType> AdapterType adaptTo(@NotNull @NotNull Class<AdapterType> type)Adapts the adaptable to another type.Please note that it is explicitly left as an implementation detail whether each call to this method with the same
typeyields the same object or a new object on each call.Implementations of this method should document their adapted types as well as their behaviour with respect to returning newly created or same instances on each call.
- Type Parameters:
AdapterType- The generic type to which this object is adapted to- Parameters:
type- The Class object of the target type, such asjavax.jcr.Node.classorjava.io.File.class- Returns:
- The adapter target or
nullif the object cannot adapt to the requested type
-
-