Replacer
constructor methods.
This API is EXPERIMENTAL. Use at your own risk.
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescriptionstatic final @NotNull Replacer
Decomposes compound queries into their component queries.static final @NotNull Replacer
listening
(Replacer replacer, BiConsumer<? super QueryPart, ? super QueryPart> replacement) Wraps anotherReplacer
, listening to all of the replacement events that it produces.static final @NotNull Replacer
mappingTable
(Function<? super Table<?>, ? extends Table<?>> replacement) AReplacer
that maps tables similar to the functionality offered bySettings.getRenderMapping()
.static final @NotNull Replacer
mappingTable
(Table<?> input, Table<?> output) AReplacer
that maps a pair of tables similar to the functionality offered bySettings.getRenderMapping()
.static final @NotNull Replacer
transformPatterns
(Configuration configuration) AReplacer
that implements theSettings.isTransformPatterns()
functionality.
-
Method Details
-
decomposing
Decomposes compound queries into their component queries.Some DDL statements are compound statements, such as e.g.
ALTER TABLE t ADD col1 INT, ADD col2 INT;
The above single compound statement can be decomposed into its component statements:
ALTER TABLE t ADD col1 INT; ALTER TABLE t ADD col2 INT;
Some use-cases, including DDL interpretation may be better served by component statements rather than the compound version.
As this
Replacer
has to adhere to the contract imposed byReplacer.replacer()
, it can only operate onQueries
and otherQuery
wrapping elements, such asBlock
and other procedural scope statements. -
listening
@NotNull public static final @NotNull Replacer listening(Replacer replacer, BiConsumer<? super QueryPart, ? super QueryPart> replacement) Wraps anotherReplacer
, listening to all of the replacement events that it produces. -
transformPatterns
AReplacer
that implements theSettings.isTransformPatterns()
functionality. -
mappingTable
@NotNull public static final @NotNull Replacer mappingTable(Function<? super Table<?>, ? extends Table<?>> replacement) AReplacer
that maps tables similar to the functionality offered bySettings.getRenderMapping()
.Ordinary
Traverser
andReplacer
implementations don't get to see the qualifyingTable
object of aTableField
, for example. This makes it laborious to map e.g.T
toU
as follows:-- Input SELECT t.x FROM t -- Output SELECT u.x FROM u
-
mappingTable
AReplacer
that maps a pair of tables similar to the functionality offered bySettings.getRenderMapping()
.Ordinary
Traverser
andReplacer
implementations don't get to see the qualifyingTable
object of aTableField
, for example. This makes it laborious to map e.g.T
toU
as follows:-- Input SELECT t.x FROM t -- Output SELECT u.x FROM u
-