com.citytechinc.aem.bedrock.api.node
Interface BasicNode

All Superinterfaces:
Accessible, ImageSource, Linkable
All Known Subinterfaces:
ComponentNode

public interface BasicNode
extends Linkable, ImageSource, Accessible

Represents a "basic" node in the JCR, typically an unstructured node that may or may not exist in a CQ page hierarchy. Examples of non-page descendant nodes that could be considered basic nodes include design nodes and arbitrary unstructured nodes that do not require inheritance capabilities.

Many methods return an Optional type where a null instance would otherwise be returned (e.g. when a descendant node is requested for a path that does not exist in the repository).


Method Summary
 String getId()
          Get the unique ID for this resource based on the path.
 int getIndex()
          Get the index of this resource in relation to sibling nodes.
 int getIndex(String resourceType)
          Get the index of this node in relation to sibling nodes, ignoring resource types that do not match the specified value.
 Optional<Node> getNode()
          Get the JCR node for this instance.
 String getPath()
          Shortcut for getting the current resource path.
 List<Property> getProperties(Predicate<Property> predicate)
          Get a list of properties that apply for the given predicate.
 Resource getResource()
          Get the underlying resource for this instance.
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Linkable
getHref, getHref, getLink, getLink, getLinkBuilder, getLinkBuilder
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.ImageSource
getImageSource, getImageSource, getImageSource, getImageSource, isHasImage, isHasImage
 
Methods inherited from interface com.citytechinc.aem.bedrock.api.Accessible
asMap, get, get, getAsHref, getAsHref, getAsHref, getAsLink, getAsLink, getAsLink, getAsList, getAsPage, getAsType, getImageReference, getImageReference, getImageRendition, getImageRendition
 

Method Detail

getId

String getId()
Get the unique ID for this resource based on the path. If this node is the descendant of a page, the page path will be removed from the identifier, since the relative path of a component node is always unique for a page.

Returns:
unique ID

getIndex

int getIndex()
Get the index of this resource in relation to sibling nodes.

Returns:
index in sibling nodes or -1 if resource is null or has null parent node

getIndex

int getIndex(String resourceType)
Get the index of this node in relation to sibling nodes, ignoring resource types that do not match the specified value.

Parameters:
resourceType - sling:resourceType to filter on
Returns:
index in sibling nodes or -1 if resource is null or has null parent node

getNode

Optional<Node> getNode()
Get the JCR node for this instance. This will return an absent Optional if the underlying resource for this instance is synthetic or non-existent.

Returns:
Optional node for this resource

getPath

String getPath()
Shortcut for getting the current resource path.

Returns:
resource path

getProperties

List<Property> getProperties(Predicate<Property> predicate)
Get a list of properties that apply for the given predicate.

Parameters:
predicate - predicate to apply
Returns:
filtered list of properties or empty list if no properties of this node apply for the given predicate

getResource

Resource getResource()
Get the underlying resource for this instance.

Returns:
current resource


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