Class PredicateUtil


  • public final class PredicateUtil
    extends Object
    Utility class that helps with common patterns found in Predicate implementations.
    • Method Detail

      • getParamFromQueryParams

        public static String getParamFromQueryParams​(org.apache.sling.api.SlingHttpServletRequest request,
                                                     String parameterName)
        Parameters:
        request - the request object.
        parameterName - The request query parameter name.
        Returns:
        a String representation of the query parameter parameterName. If no request parameter can be found with that name, the empty string is returned.
      • isOptionInInitialValues

        public static boolean isOptionInInitialValues​(com.adobe.cq.wcm.core.components.models.form.OptionItem optionItem,
                                                      org.apache.sling.api.resource.ValueMap initialValues)
        Determines if the optionItem's value exists as a value in the initialValues map.
        Parameters:
        optionItem - the option item.
        initialValues - the initial values.
        Returns:
        true if optionItem's value is in initialValues.
      • isOptionInInitialValues

        public static boolean isOptionInInitialValues​(String value,
                                                      org.apache.sling.api.resource.ValueMap initialValues)
        Determines if the value exists as a value in the initialValues map. Only String and String[] intialValues values are supported.
        Parameters:
        value - the value to check.
        initialValues - the initial values.
        Returns:
        true if value is in initialValues.
      • getInitialValue

        public static String getInitialValue​(org.apache.sling.api.SlingHttpServletRequest request,
                                             Predicate predicate,
                                             String predicateValueName)
        Finds initial predicate value from the request.
        Parameters:
        request - the request.
        predicate - the predicate.
        predicateValueName - the predicate value name.
        Returns:
        a map of the initial values.
      • getInitialValues

        public static org.apache.sling.api.resource.ValueMap getInitialValues​(org.apache.sling.api.SlingHttpServletRequest request,
                                                                              Predicate predicate,
                                                                              String predicateValueName)
        Finds initial predicate values from the request.
        Parameters:
        request - the request.
        predicate - the predicate.
        predicateValueName - the predicate value name.
        Returns:
        a map of the initial values.
      • findPredicate

        public static org.apache.sling.api.resource.ValueMap findPredicate​(Map<String,​String> queryBuilderParams,
                                                                           String predicateName,
                                                                           String predicateValueName)
        Finds the QueryBuilder map entries that pertain to the parameterized predicate. This is helpful to find out what/which parameters are already present in a parameter map.
        Parameters:
        queryBuilderParams - the params to search through.
        predicateName - the predicate name to find.
        predicateValueName - the predicateName's predicate value to find. If null, it is set to the predicateName.
        Returns:
        a map that contains the QueryBuilder params (keys and values) that match the predicateName/predicateValueName param pair.