Class SlingQuery

  • All Implemented Interfaces:
    Iterable<org.apache.sling.api.resource.Resource>

    @ProviderType
    public class SlingQuery
    extends AbstractQuery<org.apache.sling.api.resource.Resource,​SlingQuery>
    SlingQuery is a Sling resource tree traversal tool inspired by the jQuery.
    • Method Detail

      • $

        public static SlingQuery $​(org.apache.sling.api.resource.Resource... resources)
      • $

        public static SlingQuery $​(org.apache.sling.api.resource.ResourceResolver resolver)
      • map

        public <E> Iterable<E> map​(Class<? extends E> clazz)
        Transform the whole collection to a new Iterable object, invoking Adaptable.adaptTo(Class) method on each Resource. If some Resource can't be adapted to the class (eg. adaptTo() returns null), it will be skipped.
        Type Parameters:
        E - type of the clazz
        Parameters:
        clazz - Class used to adapt the Resources
        Returns:
        new iterable containing succesfully adapted Resources