com.icfolson.aem.library.api.Traversable Maven / Gradle / Ivy
package com.icfolson.aem.library.api;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import java.util.List;
/**
* Definition for hierarchical JCR resources that can be traversed.
*
* @param type of traversable resource
*/
public interface Traversable {
/**
* Find the first ancestor resource that matches the given predicate condition.
*
* @param predicate predicate to match ancestor resources against
* @return Optional
resource that matches the predicate condition
*/
Optional findAncestor(Predicate predicate);
/**
* Find the first ancestor resource that matches the given predicate condition.
*
* @param predicate predicate to match ancestor resources against
* @param excludeCurrentResource if true, the current resource will be excluded (i.e. even if the current resource
* matches the predicate criteria, it will not be returned)
* @return Optional
resource that matches the predicate condition
*/
Optional findAncestor(Predicate predicate, boolean excludeCurrentResource);
/**
* Find the first ancestor resource containing the given property name.
*
* @param propertyName property name to find on ancestor resources
* @return Optional
resource that contains the property
*/
Optional findAncestorWithProperty(String propertyName);
/**
* Find the first ancestor resource containing the given property name.
*
* @param propertyName property name to find on ancestor resources
* @param excludeCurrentResource if true, the current resource will be excluded (i.e. even if the current resource
* matches the predicate criteria, it will not be returned)
* @return Optional
resource that contains the property
*/
Optional findAncestorWithProperty(String propertyName, boolean excludeCurrentResource);
/**
* Find the first ancestor resource where the given property name has the specified value.
*
* @param propertyName property name to find on ancestor resources
* @param propertyValue value of named property to match
* @param type of value
* @return Optional
resource that contains the property value
*/
Optional findAncestorWithPropertyValue(String propertyName, V propertyValue);
/**
* Find the first ancestor resource where the given property name has the specified value.
*
* @param propertyName property name to find on ancestor resources
* @param propertyValue value of named property to match
* @param excludeCurrentResource if true, the current resource will be excluded (i.e. even if the current resource
* matches the predicate criteria, it will not be returned)
* @param type of value
* @return Optional
resource that contains the property value
*/
Optional findAncestorWithPropertyValue(String propertyName, V propertyValue, boolean excludeCurrentResource);
/**
* Get a list of descendant resources that match the given predicate condition.
*
* @param predicate predicate to match descendant resources against
* @return list of resources that match the predicate condition or empty list if none exist
*/
List findDescendants(Predicate predicate);
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy