SlingAdaptable Abstract Class

[vc_row][vc_column width=”2/3″][vc_column_text el_class=”documentation”]The abstract Java class is an implementation of the interface. By convention, implementations of the Adaptable interface should pass the adaptable processing to the if the Adapter implementation cannot provide an adapted object. The SlingAdaptable provides an easy way to follow this convention. Classes that extend the SlingAdaptable class must override the adaptTo() method. If not able to adapt the original adaptable the class must call the super.adaptTo() method to allow the to process the adaptable.



 AdapterType adaptTo(Class type);

type: the Class to return as an adapter


An object that is an instance of the class specified in the type parameter. If not able to adapt to the requested type, null is returned.

Note: AdapterType is not an interface or class. It is a type parameter for the generic type, such as the conventional symbols, E, K, N, T, V.


public class MyAdaptable extends SlingAdaptable {

	private String title;

	public MyAdaptable(String title) {
		this.title = title;

	public  AdapterType adaptTo(Class type) {
        if (type == String.class) {
            return (AdapterType) this.title;
        return super.adaptTo(type);

For Additional Information

Sling Adapter Annotation


SlingAdapter JavaDoc

GitHub: class [/vc_column_text][/vc_column][vc_column width=”1/3″][vc_widget_sidebar sidebar_id=”woocommerce”][/vc_column][/vc_row][vc_row][vc_column width=”1/2″][vc_column_text]Previous: AdapterFactory Interface[/vc_column_text][/vc_column][vc_column width=”1/2″][vc_column_text]

Next: Sling Adapter Annotations