Class ValueMapResource
- java.lang.Object
-
- org.apache.sling.api.adapter.SlingAdaptable
-
- org.apache.sling.api.resource.AbstractResource
-
- org.apache.sling.api.resource.SyntheticResource
-
- com.adobe.granite.ui.components.ds.ValueMapResource
-
public class ValueMapResource extends SyntheticResource
ASyntheticResource
that will return the passed ValueMap when this resource is adapted to ValueMap.
-
-
Field Summary
-
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING
-
-
Constructor Summary
Constructors Constructor Description ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType)
Instantiates with an empty ValueMap initially.ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType, ValueMap vm)
Instantiates with the given ValueMap.ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType, ValueMap vm, java.util.Collection<Resource> children)
Instantiates with the given child resources.ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType)
Instantiates with an empty ValueMap initially.ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType, ValueMap vm)
Instantiates with the given ValueMap.ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType, ValueMap vm, java.util.Collection<Resource> children)
Instantiates with the given child resources.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <Type> Type
adaptTo(java.lang.Class<Type> type)
Calls into the registeredAdapterManager
to adapt this object to the desiredtype
.Resource
getChild(java.lang.String relPath)
Returns the indicated child of this resource.java.lang.Iterable<Resource>
getChildren()
Returns an iterable of the direct children of this resource.boolean
hasChildren()
Checks to see if there are direct children of this resource by invokingResourceResolver.hasChildren(Resource)
.java.util.Iterator<Resource>
listChildren()
Returns an iterator on the direct child resources.-
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
-
-
-
-
Constructor Detail
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType)
Instantiates with an empty ValueMap initially.- Parameters:
resourceResolver
- The resource resolverpath
- The resource pathresourceType
- The resource type
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType, @Nonnull ValueMap vm)
Instantiates with the given ValueMap.- Parameters:
resourceResolver
- The resource resolverpath
- The resource pathresourceType
- The resource typevm
- The ValueMap of the resource
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, java.lang.String path, java.lang.String resourceType, @Nonnull ValueMap vm, @CheckForNull java.util.Collection<Resource> children)
Instantiates with the given child resources.- Parameters:
resourceResolver
- The resource resolverpath
- The resource pathresourceType
- The resource typevm
- The ValueMap of the resourcechildren
- The children of the resource
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType)
Instantiates with an empty ValueMap initially.- Parameters:
resourceResolver
- The resource resolverrm
- The resource meta dataresourceType
- The resource type
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType, @Nonnull ValueMap vm)
Instantiates with the given ValueMap.- Parameters:
resourceResolver
- The resource resolverrm
- The resource meta dataresourceType
- The resource typevm
- The ValueMap of the resource
-
ValueMapResource
public ValueMapResource(ResourceResolver resourceResolver, ResourceMetadata rm, java.lang.String resourceType, @Nonnull ValueMap vm, @CheckForNull java.util.Collection<Resource> children)
Instantiates with the given child resources.- Parameters:
resourceResolver
- The resource resolverrm
- The resource meta dataresourceType
- The resource typevm
- The ValueMap of the resourcechildren
- The children of the resource
-
-
Method Detail
-
adaptTo
public <Type> Type adaptTo(java.lang.Class<Type> type)
Description copied from class:SlingAdaptable
Calls into the registeredAdapterManager
to adapt this object to the desiredtype
.This method implements a cache of adapters to improve performance. That is repeated calls to this method with the same class will result in the same object to be returned.
- Specified by:
adaptTo
in interfaceAdaptable
- Overrides:
adaptTo
in classSlingAdaptable
- Type Parameters:
Type
- The generic type to which this resource is adapted to- Parameters:
type
- The Class object of the target type, such asjavax.jcr.Node.class
orjava.io.File.class
- Returns:
- The adapter target or
null
if the resource cannot adapt to the requested type
-
getChild
public Resource getChild(java.lang.String relPath)
Description copied from class:AbstractResource
Returns the indicated child of this resource.This method is implemented calling the
ResourceResolver.getResource(Resource, String)
method. As such therelPath
argument may even be an absolute path or a path containing relative path segments.
(current resource) and..
(parent resource).Implementations should not generally overwrite this method without calling this base class implementation.
- Specified by:
getChild
in interfaceResource
- Overrides:
getChild
in classAbstractResource
- Parameters:
relPath
- relative path to the child resource- Returns:
- The child resource or
null
- See Also:
ResourceResolver.getResource(Resource, String)
-
listChildren
public java.util.Iterator<Resource> listChildren()
Description copied from class:AbstractResource
Returns an iterator on the direct child resources.This method is implemented calling the
ResourceResolver.listChildren(Resource)
method.Implementations should not generally overwrite this method without calling this base class implementation.
- Specified by:
listChildren
in interfaceResource
- Overrides:
listChildren
in classAbstractResource
- Returns:
- An iterator for child resources.
- See Also:
ResourceResolver.listChildren(Resource)
-
getChildren
public 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 interfaceResource
- Overrides:
getChildren
in classAbstractResource
- Returns:
- An iterable for child resources
- See Also:
Resource.getChildren()
-
hasChildren
public boolean hasChildren()
Description copied from class:AbstractResource
Checks to see if there are direct children of this resource by invokingResourceResolver.hasChildren(Resource)
.- Specified by:
hasChildren
in interfaceResource
- Overrides:
hasChildren
in classAbstractResource
- Returns:
true
if the resource has any child resources
-
-