Class RenditionPatternPicker

  • All Implemented Interfaces:
    com.day.cq.dam.api.RenditionPicker

    @ProviderType
    public class RenditionPatternPicker
    extends Object
    implements com.day.cq.dam.api.RenditionPicker
    RenditionPicker that picks Assets based on a Regex pattern that matches against Rendition names.
    • Constructor Detail

      • RenditionPatternPicker

        public RenditionPatternPicker​(String pattern)
        Create an Asset Rendition Picker that will pick a Rendition by matching the supplied Regex pattern (as String).
        Parameters:
        pattern - Regex pattern to match against Rendition names.
      • RenditionPatternPicker

        public RenditionPatternPicker​(Pattern pattern)
        Create an Asset Rendition Picker that will pick a Rendition by matching the supplied Regex pattern.
        Parameters:
        pattern - Pattern used to find the Asset rendition
    • Method Detail

      • getRendition

        public final com.day.cq.dam.api.Rendition getRendition​(com.day.cq.dam.api.Asset asset)
        Gets the rendition which matches against the constructor's Regex pattern.

        If no matches are made and an Original exists, returns the Original.

        If no matches are made and an Original doesn't exist, return the first Rendition.

        Specified by:
        getRendition in interface com.day.cq.dam.api.RenditionPicker
        Parameters:
        asset - Asset whose Renditions will be selected.
        Returns:
        The first rendition whose name matches the supplied pattern (via constructor).