Package google.registry.util
Class SqlTemplate
java.lang.Object
google.registry.util.SqlTemplate
SQL template variable substitution.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns the freshly substituted SQL code.static SqlTemplate
Returns a new immutable SQL template builder object, for query parameter substitution.Adds a key/value that should be substituted an individual variable in the template.
-
Method Details
-
create
Returns a new immutable SQL template builder object, for query parameter substitution. -
put
Adds a key/value that should be substituted an individual variable in the template.Your template variables should appear as follows:
WHERE foo = '%BAR%'
and you would call.put("BAR", "some value"
to safely substitute it with a value. Only allow-listed characters (as defined byLEGAL_SUBSTITUTIONS
) are allowed in values.- Parameters:
key
- uppercase string that can have digits and underscoresvalue
- substitution value, composed of allow-listed characters- Throws:
IllegalArgumentException
- if key or value has bad chars or duplicate keys were added
-
build
Returns the freshly substituted SQL code.- Throws:
IllegalArgumentException
- if any substitution variable is not found in the template, or if there are any variable-like strings (%something%) left after substitution.
-