Class ResourceWrapper

    • Constructor Detail

      • ResourceWrapper

        public ResourceWrapper​(@NotNull
                               @NotNull Resource resource)
        Creates a new wrapper instance delegating all method calls to the given resource.
        Parameters:
        resource - The resource to wrap
    • Method Detail

      • getResource

        @NotNull
        public @NotNull Resource getResource()
        Returns the Resource wrapped by this instance. This method can be overwritten by subclasses if required. All methods implemented by this class use this method to get the resource object.
        Returns:
        The resource wrapped by this instance.
      • getPath

        @NotNull
        public @NotNull java.lang.String getPath()
        Returns the value of calling getPath on the wrapped resource.
        Specified by:
        getPath in interface Resource
        Returns:
        The resource path
      • getName

        @NotNull
        public @NotNull java.lang.String getName()
        Returns the value of calling getName on the wrapped resource.
        Specified by:
        getName in interface Resource
        Returns:
        The resource name
        Since:
        2.1.0 (Sling API Bundle 2.1.0)
      • getChildren

        @NotNull
        public @NotNull java.lang.Iterable<Resource> getChildren()
        Description copied from interface: Resource
        Returns an iterable of the direct children of this resource.

        This method is a convenience and returns exactly the same resources as calling getResourceResolver().getChildren(resource).

        Specified by:
        getChildren in interface Resource
        Returns:
        An iterable for child resources
        See Also:
        Resource.getChildren()
      • getResourceType

        @NotNull
        public @NotNull java.lang.String getResourceType()
        Returns the value of calling getResourceType on the wrapped resource.
        Specified by:
        getResourceType in interface Resource
        Returns:
        The resource type
      • getResourceSuperType

        public java.lang.String getResourceSuperType()
        Returns the value of calling getResourceSuperType on the wrapped resource.
        Specified by:
        getResourceSuperType in interface Resource
        Returns:
        The super type of the resource or null.
      • hasChildren

        public boolean hasChildren()
        Returns the value of calling hasChildren on the wrapped resource.
        Specified by:
        hasChildren in interface Resource
        Returns:
        true if the resource has any child resources
        Since:
        2.4.4 (Sling API Bundle 2.5.0)
      • isResourceType

        public boolean isResourceType​(java.lang.String resourceType)
        Returns the value of calling isResourceType on the wrapped resource.
        Specified by:
        isResourceType in interface Resource
        Parameters:
        resourceType - the resource type to check this resource against
        Returns:
        true if the resource type or any of the resource's super type(s) equals the given resource type, false otherwise; false can also be returned if resourceType is null
        Since:
        2.1.0 (Sling API Bundle 2.1.0)
        See Also:
        ResourceResolver.isResourceType(Resource, String)
      • adaptTo

        public <AdapterType> AdapterType adaptTo​(@NotNull
                                                 @NotNull java.lang.Class<AdapterType> type)
        Returns the value of calling adaptTo on the wrapped resource.
        Specified by:
        adaptTo in interface Adaptable
        Type Parameters:
        AdapterType - The generic type to which this object is adapted to
        Parameters:
        type - The Class object of the target type, such as javax.jcr.Node.class or java.io.File.class
        Returns:
        The adapter target or null if the object cannot adapt to the requested type
      • getValueMap

        @NotNull
        public @NotNull ValueMap getValueMap()
        Description copied from interface: Resource
        Returns a value map for this resource. The value map allows to read the properties of the resource.
        Specified by:
        getValueMap in interface Resource
        Returns:
        A value map
        See Also:
        Resource.getValueMap()
      • toString

        public java.lang.String toString()
        Returns a string representation of this wrapper consisting of the class' simple name, the resource type and path as well as the string representation of the wrapped resource.
        Overrides:
        toString in class java.lang.Object