All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.sling.api.adapter.Adaptable Maven / Gradle / Ivy

Go to download

The Apache Sling API defines an extension to the Servlet API 2.4 to provide access to content and unified access to request parameters hiding the differences between the different methods of transferring parameters from client to server. Note that the Apache Sling API bundle does not include the Servlet API but instead requires the API to be provided by the Servlet container in which the Apache Sling framework is running or by another bundle.

There is a newer version: 2.27.6
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.sling.api.adapter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import aQute.bnd.annotation.ConsumerType;

/**
 * The Adaptable interface identifies objects which can be adapted
 * to other types or representations of the same object. For example a JCR Node
 * based {@link org.apache.sling.api.resource.Resource} can adapt to the
 * underlying JCR Node or a file based resource could adapt to the underlying
 * java.io.File.
 */
@ConsumerType
public interface Adaptable {

    /**
     * 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 type yields 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. * * @param The generic type to which this object is adapted * to * @param type The Class object of the target type, such as * javax.jcr.Node.class or * java.io.File.class * @return The adapter target or null if the object cannot * adapt to the requested type */ @CheckForNull AdapterType adaptTo(@Nonnull Class type); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy