public AdapterType adaptTo()

in sfsresourceprovider/src/main/java/org/apache/sling/sfsresource/impl/FileResource.java [104:128]


    public <AdapterType> AdapterType adaptTo(final Class<AdapterType> type) {
        if (type == File.class) {
            return type.cast(this.file);
        } else if (type == InputStream.class) {
            if (file.isFile() && file.canRead()) {
                try {
                    return type.cast(new FileInputStream(file));
                } catch (final IOException ioe) {
                    LOGGER.info("adaptTo: Cannot open a stream on the file " + file, ioe);
                }
            } else {
                LOGGER.debug("adaptTo: File {} is not a readable file", file);
            }
        } else if (type == URL.class) {
            try {
                return type.cast(file.toURI().toURL());
            } catch (MalformedURLException mue) {
                LOGGER.info("adaptTo: Cannot convert the file path " + file + " to an URL", mue);
            }
        } else if (type == ValueMap.class) {
            return type.cast(getValueMap());
        }

        return super.adaptTo(type);
    }