Package org.fryske_akademy.jpa
Class Param.Builder
java.lang.Object
org.fryske_akademy.jpa.Param.Builder
- Enclosing class:
Param
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 optionally using a converter => syntax support also for non String values, no wildcard support when converter is used
Users may use syntax in values they submit, see OPERATOR
- wildcards: * and ?
- !
- (!)is null
- (!)is empty
- (!)is blank
- (!)>(=)
- (!)<(=)
- 1 <=> 10
- 1 <=> 10 AND >12
- < 3 OR >6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class* => %, ?static interfacetranslation table for wildcards -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBuilder()Builder with syntax support in value (!Builder(boolean caseInsensitive) CallsBuilder(boolean, WildcardMapping, boolean)} with true, null and the caseInsensitive argument.Builder(boolean syntaxInValue, Param.Builder.WildcardMapping wildcardMapping, boolean caseInsensitive) -
Method Summary
Modifier and TypeMethodDescriptionadd(String paramKey, String paramValue, String operator, boolean or, com.vectorprint.StringConverter converter) add(String propertyPath, String paramKey, String paramValue, com.vectorprint.StringConverter converter) add(String propertyPath, String paramKey, String operator, Object paramValue, boolean not, boolean or) Callsadd(String, String, String, Object, boolean, boolean, Object)with null for maxValueadd(String propertyPath, String paramKey, String operator, Object paramValue, boolean not, boolean or, Object maxValue) add(String propertyPath, String paramKey, String operator, String paramValue, boolean or, com.vectorprint.StringConverter converter) Bottleneck method for String values, applies syntax support and wildcard mapping when configured in the Builder.add(String propertyPath, String paramKey, OPERATOR operator, Object paramValue, boolean not, boolean or) Callsadd(String, String, OPERATOR, Object, boolean, boolean, Object)with null for maxValueadd(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.build()Also useful if for example you need to add parameters yielded by another buildercheckNotNull(String propertyPath) Add aParamthat checks if propertyPath is not nullclear()booleancontainsKey(String key) booleanisNegation(String value) check if a string (user value) indicates a negation when syntaxInValue is usedbooleanwhen true user input is parsed for syntax, seeOPERATORsetGroupEndsLastParam(int group) how many groups does the last parameter end, ")";setGroupEndsParam(int group, int paramIndex) setGroupEndsParam(int group, String key) setGroupStartsLastParam(int group) how many groups does the last parameter start, "(";setGroupStartsParam(int group, int paramIndex) setGroupStartsParam(int group, String key)
-
Field Details
-
DEFAULT_MAPPING
-
-
Constructor Details
-
Builder
public Builder(boolean syntaxInValue, Param.Builder.WildcardMapping wildcardMapping, boolean caseInsensitive) -
Builder
public Builder()Builder with syntax support in value (!, >[=], <[=], [!]is null, [!]is empty, [!]is blank). CallsBuilder(boolean, WildcardMapping, boolean)with true, null and false. -
Builder
public Builder(boolean caseInsensitive) CallsBuilder(boolean, WildcardMapping, boolean)} with true, null and the caseInsensitive argument.- Parameters:
caseInsensitive-
-
-
Method Details
-
add
- Parameters:
paramKey-paramValue-- Returns:
-
add
- Parameters:
paramKey-paramValue-or-- Returns:
-
add
Callsadd(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, com.vectorprint.StringConverter)oradd(java.lang.String, java.lang.String, org.fryske_akademy.jpa.OPERATOR, java.lang.Object, boolean, boolean, java.lang.Object)- Parameters:
propertyPath-paramKey-paramValue-or- first- Returns:
-
add
public Param.Builder add(String paramKey, String paramValue, com.vectorprint.StringConverter converter) - Parameters:
paramKey-paramValue-converter- seeStringConverter- Returns:
-
add
public Param.Builder add(String propertyPath, String paramKey, String paramValue, com.vectorprint.StringConverter converter) - Parameters:
propertyPath-paramKey-paramValue-converter- seeStringConverter- Returns:
-
add
public Param.Builder add(String paramKey, String paramValue, boolean or, com.vectorprint.StringConverter converter) - Parameters:
paramKey-paramValue-or-converter- seeStringConverter- Returns:
-
add
public Param.Builder add(String paramKey, String paramValue, String operator, boolean or, com.vectorprint.StringConverter converter) - 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, applies syntax support and wildcard mapping when configured in the Builder. Applies conversion when a converter is supplied. NOTE that when using AND or OR in paramValue and syntax support is enabled, 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. Callsadd(String, String, OPERATOR, Object, boolean, boolean, Object)} withOPERATOR.operator(String, String, boolean)for the operator. The value will be the empty string whenOPERATOR.valueIsOperator(String, boolean)is true, will beStringConverter.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- seeStringConverter- Returns:
-
checkNotNull
Add aParamthat checks if propertyPath is not null- Parameters:
propertyPath-- Returns:
-
setGroupStartsLastParam
how many groups does the last parameter start, "(";- Returns:
-
setGroupStartsParam
-
setGroupStartsParam
-
setGroupEndsLastParam
how many groups does the last parameter end, ")";- Returns:
-
setGroupEndsParam
-
setGroupEndsParam
-
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- forOPERATOR.BETWEEN- Returns:
- Throws:
IllegalArgumentException- when paramKey is already present
-
add
public Param.Builder add(String propertyPath, String paramKey, OPERATOR operator, Object paramValue, boolean not, boolean or) Callsadd(String, String, OPERATOR, Object, boolean, boolean, Object)with null for maxValue- Parameters:
propertyPath-paramKey-operator-paramValue-not-or-- Returns:
-
add
public Param.Builder add(String propertyPath, String paramKey, String operator, Object paramValue, boolean not, boolean or, Object maxValue) Callsadd(String, String, OPERATOR, Object, boolean, boolean, Object)withOPERATOR.fromToken(String)- Parameters:
propertyPath-paramKey-operator-paramValue-not-or-maxValue- forOPERATOR.BETWEEN- Returns:
-
add
public Param.Builder add(String propertyPath, String paramKey, String operator, Object paramValue, boolean not, boolean or) Callsadd(String, String, String, Object, boolean, boolean, Object)with null for maxValue- Parameters:
propertyPath-paramKey-operator-paramValue-not-or-- Returns:
-
remove
-
clear
-
isNegation
check if a string (user value) indicates a negation when syntaxInValue is used- Parameters:
value-- Returns:
- See Also:
-
addParam
-
addParam
-
build
Also useful if for example you need to add parameters yielded by another builder- Returns:
-
isSyntaxInValue
public boolean isSyntaxInValue()when true user input is parsed for syntax, seeOPERATOR- Returns:
-
containsKey
-