Class Param.Builder

  • Enclosing class:
    Param

    public static class Param.Builder
    extends Object
    A factory for Param objects, parameter values can be added in two ways:
    • as (the correct) Object => only syntax and wildcard support for String values
    • as a String using a converter => syntax support also for non String values, no wildcard support

    Users may use syntax in values they submit (comparisons must be at the start):

    • wildcards: * and ?
    • !
    • (!)is null
    • (!)is empty
    • (!)is blank
    • (!)>(=)
    • (!)<(=)
    • 1 <=> 10
    • 1 <=> 10 AND >12
    • < 3 OR >6

    • Method Detail

      • add

        public Param.Builder add​(String paramKey,
                                 Object paramValue)
        This method is suitable when your paramValue is the correct object for the query to be executed. It uses "like" as operator for String, otherwise "=".
        Parameters:
        paramKey -
        paramValue -
        Returns:
      • add

        public Param.Builder add​(String paramKey,
                                 Object paramValue,
                                 boolean or)
        This method is suitable when your paramValue is the correct object for the query to be executed. It uses "like" as operator for String, otherwise "=".
        Parameters:
        paramKey -
        paramValue -
        or - will be prepended to parameters in the query except the first
        Returns:
      • add

        public Param.Builder add​(String propertyPath,
                                 String paramKey,
                                 Object paramValue,
                                 boolean or)
        This method is suitable when your paramValue is the correct object for the query to be executed. The propertyPath may differ from key allowing you to apply multiple comparisons for the same propertyPath (i.e. e.column1=:column1 or e.column1=:column2). It uses "like" as operator for String, otherwise "=".
        Parameters:
        propertyPath -
        paramKey -
        paramValue -
        or - will be prepended to parameters in the query except the first
        Returns:
      • add

        public Param.Builder add​(String paramKey,
                                 String paramValue,
                                 com.vectorprint.StringConverter converter)
        This method is suitable when your paramValue is a String that must be converted to get the correct object for the query to be executed. It uses "like" as operator when converter is null otherwise "=".
        Parameters:
        paramKey -
        paramValue -
        converter - see StringConverter
        Returns:
      • add

        public Param.Builder add​(String propertyPath,
                                 String paramKey,
                                 String paramValue,
                                 com.vectorprint.StringConverter converter)
        This method is suitable when your paramValue is a String that must be converted to get the correct object for the query to be executed. The propertyPath may differ from key allowing you to apply multiple comparisons for the same propertyPath (i.e. e.column1=:column1 or e.column1=:column2). It uses "like" as operator when converter is null otherwise "=".
        Parameters:
        propertyPath -
        paramKey -
        paramValue -
        converter - see StringConverter
        Returns:
      • add

        public Param.Builder add​(String paramKey,
                                 String paramValue,
                                 boolean or,
                                 com.vectorprint.StringConverter converter)
        This method is suitable when your paramValue is a String that must be converted to get the correct object for the query to be executed. It uses "like" as operator when converter is null otherwise "=".
        Parameters:
        paramKey -
        paramValue -
        or -
        converter - see StringConverter
        Returns:
      • add

        public Param.Builder add​(String paramKey,
                                 String paramValue,
                                 String operator,
                                 boolean or,
                                 com.vectorprint.StringConverter converter)
        Assumes key and propertyPath are the same
        Parameters:
        paramKey -
        paramValue -
        operator -
        or -
        converter -
        Returns:
      • add

        public Param.Builder add​(String propertyPath,
                                 String paramKey,
                                 String operator,
                                 String paramValue,
                                 boolean or,
                                 com.vectorprint.StringConverter converter)
        Bottleneck method for String values, when configured in the Builder, applies syntax support and wildcard mapping, applies conversion when a converter is supplied. NOTE that when using AND or OR as syntax, multiple parameters will be added, where the name of the key is the concatenation of the original key with the index of the parameter added, starting at 0. Calls add(String, String, OPERATOR, Object, boolean, boolean, Object) } with OPERATOR.operator(String, String, boolean) for the operator. The value will be the empty string when OPERATOR.valueIsOperator(String, boolean) is true, will be StringConverter.convert(java.lang.String) when a converter is provided (negation is stripped), otherwise the value is returned with wildcards replaced and negation stripped (provided syntax support in values is active).
        Parameters:
        propertyPath - The propertyPath may differ from key allowing you to apply multiple comparisons for the same propertyPath (i.e. e.column1=:column1 or e.column1=:column2).
        paramKey -
        operator -
        paramValue -
        or -
        converter - see StringConverter
        Returns:
      • setGroupStartsLastParam

        public Param.Builder setGroupStartsLastParam​(int group)
        how many groups does the last parameter start, "(";
        Returns:
      • setGroupStartsParam

        public Param.Builder setGroupStartsParam​(int group,
                                                 int paramIndex)
      • setGroupEndsLastParam

        public Param.Builder setGroupEndsLastParam​(int group)
        how many groups does the last parameter end, ")";
        Returns:
      • setGroupEndsParam

        public Param.Builder setGroupEndsParam​(int group,
                                               int paramIndex)
      • add

        public Param.Builder add​(String propertyPath,
                                 String paramKey,
                                 OPERATOR operator,
                                 Object paramValue,
                                 boolean not,
                                 boolean or,
                                 Object maxValue)
        Bottleneck method, adds a new Param, does not apply any intelligence.
        Parameters:
        propertyPath - The propertyPath may differ from key allowing you to apply multiple comparisons for the same propertyPath (i.e. e.column1=:column1 or e.column1=:column2).
        paramKey -
        operator -
        paramValue -
        not -
        or -
        maxValue - for OPERATOR.BETWEEN
        Returns:
        Throws:
        IllegalArgumentException - when paramKey is already present, value is null or invalid BETWEEN values
      • isNegation

        public boolean isNegation​(String value)
        check if a string (user value) indicates a negation when syntaxInValue is used
        Parameters:
        value -
        Returns:
        See Also:
        OPERATOR.negation(String)
      • build

        public List<Param> build()
        usefull if for example you need to add parameters yielded by a diffently configured builder
        Returns:
      • isSyntaxInValue

        public boolean isSyntaxInValue()
        when true wildcards are not replaced and syntax in value is not applied
        Returns:
      • containsKey

        public boolean containsKey​(String key)