com.citytechinc.aem.bedrock.api
Interface Accessible

All Known Subinterfaces:
BasicNode, ComponentNode, PageDecorator

public interface Accessible

Definition of accessor methods for content resources for Node and Page instances.


Method Summary
 ValueMap asMap()
           
<T> Optional<T>
get(String propertyName, Class<T> type)
          Get a property value from the current node.
<T> T
get(String propertyName, T defaultValue)
          Get a property value from the current node, returning the default value if the property does not exist.
 Optional<String> getAsHref(String propertyName)
          Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource (i.e.
 Optional<String> getAsHref(String propertyName, boolean strict)
          Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource.
 Optional<String> getAsHref(String propertyName, boolean strict, boolean mapped)
          Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource.
 Optional<Link> getAsLink(String propertyName)
          Given a property on this resource containing the path of another resource, get a link to the resource.
 Optional<Link> getAsLink(String propertyName, boolean strict)
          Given a property on this resource containing the path of another resource, get a link to the resource.
 Optional<Link> getAsLink(String propertyName, boolean strict, boolean mapped)
          Given a property on this resource containing the path of another resource, get a link to the resource.
<T> List<T>
getAsList(String propertyName, Class<T> type)
          Get a multi-valued property from the current node as a list of the given type.
 Optional<PageDecorator> getAsPage(String propertyName)
          Get a page instance from the value of the given property.
<AdapterType>
Optional<AdapterType>
getAsType(String propertyName, Class<AdapterType> type)
          Get an Optional type instance for a property on this resource containing the path of another Resource in the repository.
 Optional<String> getImageReference()
          Get the referenced DAM asset path for the default image (named "image") for this component.
 Optional<String> getImageReference(String name)
           
 Optional<String> getImageRendition(String renditionName)
          Get the DAM asset rendition path for the default image (named "image") for this component.
 Optional<String> getImageRendition(String name, String renditionName)
           
 

Method Detail

asMap

ValueMap asMap()
Returns:
map of property names to values, or empty map if underlying resource is null or nonexistent

get

<T> T get(String propertyName,
          T defaultValue)
Get a property value from the current node, returning the default value if the property does not exist.

Type Parameters:
T - property type
Parameters:
propertyName - property name
defaultValue - default value
Returns:
property value or default value if it does not exist

get

<T> Optional<T> get(String propertyName,
                    Class<T> type)
Get a property value from the current node. This returns the same value as the underlying ValueMap wrapped in an Optional instance instead of returning null.

Type Parameters:
T - property type
Parameters:
propertyName - property name
type - property type
Returns:
Optional of the given type containing the property value or absent if the property does not exist

getAsHref

Optional<String> getAsHref(String propertyName)
Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource (i.e. the content path with ".html" appended).

Parameters:
propertyName - name of property containing a valid content path
Returns:
href value wrapped in an Optional

getAsHref

Optional<String> getAsHref(String propertyName,
                           boolean strict)
Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource. Use this method with a true argument when appending ".html" to the resource path is desired only for valid CQ pages and not external paths.

Parameters:
propertyName - name of property containing a valid content path
strict - if true, strict resource resolution will be applied and only valid CQ content paths will have ".html" appended
Returns:
href value wrapped in an Optional

getAsHref

Optional<String> getAsHref(String propertyName,
                           boolean strict,
                           boolean mapped)
Given a property on this resource containing the path of another resource, get an Optional containing the href to the resource. Use this method with a true argument when appending ".html" to the resource path is desired only for valid CQ pages and not external paths. Setting mapped to true will map the path value, if it exists, through the Sling Resource Resolver.

Parameters:
propertyName - name of property containing a valid content path
strict - if true, strict resource resolution will be applied and only valid CQ content paths will have ".html" appended
mapped - if true, the property value will be routed through the Resource Resolver to determine the mapped path for the value. For example, if a mapping from "/content/" to "/" exists in the Apache Sling Resource Resolver Factory OSGi configuration, getting the mapped href for the path "/content/citytechinc" will return "/citytechinc.html".
Returns:
href value wrapped in an Optional

getAsLink

Optional<Link> getAsLink(String propertyName)
Given a property on this resource containing the path of another resource, get a link to the resource.

Parameters:
propertyName - name of property containing a valid content path
Returns:
Optional link object, absent if property does not contain a valid content path

getAsLink

Optional<Link> getAsLink(String propertyName,
                         boolean strict)
Given a property on this resource containing the path of another resource, get a link to the resource. Use this method with a true argument when including an extension for the link is desired only for valid CQ pages and not external paths.

Parameters:
propertyName - name of property containing a valid content path
strict - if true, strict resource resolution will be applied and only valid CQ content paths will have an extension
Returns:
Optional link object, absent if property does not contain a valid content path

getAsLink

Optional<Link> getAsLink(String propertyName,
                         boolean strict,
                         boolean mapped)
Given a property on this resource containing the path of another resource, get a link to the resource. Use this method with a true argument when including an extension for the link is desired only for valid CQ pages and not external paths. Setting mapped to true will map the path value, if it exists, through the Sling Resource Resolver.

Parameters:
propertyName - name of property containing a valid content path
strict - if true, strict resource resolution will be applied and only valid CQ content paths will have an extension
mapped - if true, the property value will be routed through the Resource Resolver to determine the mapped path for the value. For example, if a mapping from "/content/" to "/" exists in the Apache Sling Resource Resolver Factory OSGi configuration, the Link path will be "/citytechinc" rather than "/content/citytechinc".
Returns:
Optional link object, absent if property does not contain a valid content path

getAsList

<T> List<T> getAsList(String propertyName,
                      Class<T> type)
Get a multi-valued property from the current node as a list of the given type.

Type Parameters:
T - property type, must be supported by ValueMap
Parameters:
propertyName - name of multi-valued property
type - property type
Returns:
list of property values or an empty list if the property does not exist

getAsPage

Optional<PageDecorator> getAsPage(String propertyName)
Get a page instance from the value of the given property. Will return an absent Optional if the path value for the given property name does not resolve to a valid CQ page.

Parameters:
propertyName - property name
Returns:
Optional page for property value

getAsType

<AdapterType> Optional<AdapterType> getAsType(String propertyName,
                                              Class<AdapterType> type)
Get an Optional type instance for a property on this resource containing the path of another Resource in the repository.

Type Parameters:
AdapterType - adapter class that is adaptable from Resource
Parameters:
propertyName - name of property containing a resource path
type - type to adapt from resource
Returns:
Optional instance of the specified type, or absent if either the property does not exist or the resource does not adapt to the provided type

getImageReference

Optional<String> getImageReference()
Get the referenced DAM asset path for the default image (named "image") for this component.

Returns:
Optional image reference path

getImageReference

Optional<String> getImageReference(String name)
Parameters:
name - image name
Returns:
Optional image reference path

getImageRendition

Optional<String> getImageRendition(String renditionName)
Get the DAM asset rendition path for the default image (named "image") for this component.

Parameters:
renditionName - rendition name for this asset (e.g. "cq5dam.thumbnail.140.100.png")
Returns:
Optional image rendition path

getImageRendition

Optional<String> getImageRendition(String name,
                                   String renditionName)
Parameters:
name - image name
renditionName - rendition name for this asset
Returns:
Optional image rendition path


Copyright © 2015 CITYTECH, Inc.. All rights reserved.