Class GraniteUiSyntheticResource

  • All Implemented Interfaces:
    org.apache.sling.api.adapter.Adaptable, org.apache.sling.api.resource.Resource

    @ProviderType
    public final class GraniteUiSyntheticResource
    extends org.apache.sling.api.resource.SyntheticResource
    Extended version of SyntheticResource that allows to pass an own value map and optional child resources. Please note: Accessing child resources does only work when accessing Resource.listChildren(), and not when calling the same method on resourceResolver. This breaks the contract of the resource API, but should work at least for the Granite UI implementation which seems to always use this method.
    • Field Summary

      • Fields inherited from interface org.apache.sling.api.resource.Resource

        RESOURCE_TYPE_NON_EXISTING
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <Type> Type adaptTo​(java.lang.Class<Type> type)  
      static org.apache.sling.api.resource.Resource child​(@NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull java.lang.String name, @NotNull java.lang.String resourceType)
      Create synthetic resource child resource of the given parent resource.
      static org.apache.sling.api.resource.Resource child​(@NotNull org.apache.sling.api.resource.Resource parentResource, @NotNull java.lang.String name, @NotNull java.lang.String resourceType, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
      Create synthetic resource child resource of the given parent resource.
      static void copySubtree​(@NotNull org.apache.sling.api.resource.Resource targetParent, @NotNull org.apache.sling.api.resource.Resource source)
      Copy the given source resource as synthetic child under the target parent resource, including all children.
      static org.apache.sling.api.resource.Resource create​(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
      Create synthetic resource.
      static org.apache.sling.api.resource.Resource create​(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable java.lang.String path, @NotNull java.lang.String resourceType)
      Create synthetic resource.
      static org.apache.sling.api.resource.Resource create​(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @Nullable java.lang.String path, @NotNull java.lang.String resourceType, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
      Create synthetic resource.
      org.apache.sling.api.resource.Resource getChild​(java.lang.String relPath)  
      java.lang.Iterable<org.apache.sling.api.resource.Resource> getChildren()  
      boolean hasChildren()  
      java.util.Iterator<org.apache.sling.api.resource.Resource> listChildren()  
      static org.apache.sling.api.resource.Resource wrap​(@NotNull org.apache.sling.api.resource.Resource resource)
      Wrap a real resource and create a synthetic resource out of it.
      static org.apache.sling.api.resource.Resource wrap​(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
      Wrap a real resource and create a synthetic resource out of it.
      static org.apache.sling.api.resource.Resource wrapMerge​(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.ValueMap valueMap)
      Wrap a real resource and create a synthetic resource out of it.
      • Methods inherited from class org.apache.sling.api.resource.SyntheticResource

        getPath, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, toString
      • Methods inherited from class org.apache.sling.api.resource.AbstractResource

        getName, getParent, getValueMap, isResourceType
      • Methods inherited from class org.apache.sling.api.adapter.SlingAdaptable

        setAdapterManager, unsetAdapterManager
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • adaptTo

        public <Type> Type adaptTo​(java.lang.Class<Type> type)
        Specified by:
        adaptTo in interface org.apache.sling.api.adapter.Adaptable
        Overrides:
        adaptTo in class org.apache.sling.api.adapter.SlingAdaptable
      • listChildren

        public java.util.Iterator<org.apache.sling.api.resource.Resource> listChildren()
        Specified by:
        listChildren in interface org.apache.sling.api.resource.Resource
        Overrides:
        listChildren in class org.apache.sling.api.resource.AbstractResource
      • getChildren

        public java.lang.Iterable<org.apache.sling.api.resource.Resource> getChildren()
        Specified by:
        getChildren in interface org.apache.sling.api.resource.Resource
        Overrides:
        getChildren in class org.apache.sling.api.resource.AbstractResource
      • hasChildren

        public boolean hasChildren()
        Specified by:
        hasChildren in interface org.apache.sling.api.resource.Resource
        Overrides:
        hasChildren in class org.apache.sling.api.resource.AbstractResource
      • getChild

        public org.apache.sling.api.resource.Resource getChild​(java.lang.String relPath)
        Specified by:
        getChild in interface org.apache.sling.api.resource.Resource
        Overrides:
        getChild in class org.apache.sling.api.resource.AbstractResource
      • create

        public static org.apache.sling.api.resource.Resource create​(@NotNull
                                                                    @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                    @NotNull
                                                                    @NotNull org.apache.sling.api.resource.ValueMap valueMap)
        Create synthetic resource.
        Parameters:
        resourceResolver - Resource resolver
        valueMap - Properties
        Returns:
        Resource
      • create

        public static org.apache.sling.api.resource.Resource create​(@NotNull
                                                                    @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                    @Nullable
                                                                    @Nullable java.lang.String path,
                                                                    @NotNull
                                                                    @NotNull java.lang.String resourceType)
        Create synthetic resource.
        Parameters:
        resourceResolver - Resource resolver
        path - Resource path
        resourceType - Resource type
        Returns:
        Resource
      • create

        public static org.apache.sling.api.resource.Resource create​(@NotNull
                                                                    @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver,
                                                                    @Nullable
                                                                    @Nullable java.lang.String path,
                                                                    @NotNull
                                                                    @NotNull java.lang.String resourceType,
                                                                    @NotNull
                                                                    @NotNull org.apache.sling.api.resource.ValueMap valueMap)
        Create synthetic resource.
        Parameters:
        resourceResolver - Resource resolver
        path - Resource path
        resourceType - Resource type
        valueMap - Properties
        Returns:
        Resource
      • wrap

        public static org.apache.sling.api.resource.Resource wrap​(@NotNull
                                                                  @NotNull org.apache.sling.api.resource.Resource resource)
        Wrap a real resource and create a synthetic resource out of it.
        Parameters:
        resource - Real resource
        Returns:
        Resource
      • wrap

        public static org.apache.sling.api.resource.Resource wrap​(@NotNull
                                                                  @NotNull org.apache.sling.api.resource.Resource resource,
                                                                  @NotNull
                                                                  @NotNull org.apache.sling.api.resource.ValueMap valueMap)
        Wrap a real resource and create a synthetic resource out of it.
        Parameters:
        resource - Real resource
        valueMap - Properties to use instead of the real properties
        Returns:
        Resource
      • wrapMerge

        public static org.apache.sling.api.resource.Resource wrapMerge​(@NotNull
                                                                       @NotNull org.apache.sling.api.resource.Resource resource,
                                                                       @NotNull
                                                                       @NotNull org.apache.sling.api.resource.ValueMap valueMap)
        Wrap a real resource and create a synthetic resource out of it. Merges the given properties with the existing properties of the resource.
        Parameters:
        resource - Real resource
        valueMap - Properties to be merged with the real properties
        Returns:
        Resource
      • child

        public static org.apache.sling.api.resource.Resource child​(@NotNull
                                                                   @NotNull org.apache.sling.api.resource.Resource parentResource,
                                                                   @NotNull
                                                                   @NotNull java.lang.String name,
                                                                   @NotNull
                                                                   @NotNull java.lang.String resourceType)
        Create synthetic resource child resource of the given parent resource.
        Parameters:
        parentResource - Parent resource (has to be a GraniteUiSyntheticResource instance)
        name - Child resource name
        resourceType - Resource type
        Returns:
        Resource
      • child

        public static org.apache.sling.api.resource.Resource child​(@NotNull
                                                                   @NotNull org.apache.sling.api.resource.Resource parentResource,
                                                                   @NotNull
                                                                   @NotNull java.lang.String name,
                                                                   @NotNull
                                                                   @NotNull java.lang.String resourceType,
                                                                   @NotNull
                                                                   @NotNull org.apache.sling.api.resource.ValueMap valueMap)
        Create synthetic resource child resource of the given parent resource.
        Parameters:
        parentResource - Parent resource (has to be a GraniteUiSyntheticResource instance)
        name - Child resource name
        resourceType - Resource type
        valueMap - Properties
        Returns:
        Resource
      • copySubtree

        public static void copySubtree​(@NotNull
                                       @NotNull org.apache.sling.api.resource.Resource targetParent,
                                       @NotNull
                                       @NotNull org.apache.sling.api.resource.Resource source)
        Copy the given source resource as synthetic child under the target parent resource, including all children.
        Parameters:
        targetParent - Target parent resource
        source - Source resource