public static final class ReservedWordSymbolProvider.Builder
extends java.lang.Object
ReservedWordSymbolProvider
.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
SymbolProvider |
build()
Builds a
SymbolProvider implementation that wraps another
symbol provider and escapes its results. |
ReservedWordSymbolProvider.Escaper |
buildEscaper()
Builds a
SymbolProvider.Escaper that is used to manually
escape Symbol s and member names. |
ReservedWordSymbolProvider.Builder |
escapePredicate(java.util.function.BiPredicate<Shape,Symbol> escapePredicate)
Sets a predicate that is used to control when a shape + symbol
combination should be checked if it's a reserved word.
|
ReservedWordSymbolProvider.Builder |
filenameReservedWords(ReservedWords filenameReservedWords)
Sets the reserved word implementation for file names.
|
ReservedWordSymbolProvider.Builder |
memberReservedWords(ReservedWords memberReservedWords)
Sets the reserved word implementation for members.
|
ReservedWordSymbolProvider.Builder |
nameReservedWords(ReservedWords nameReservedWords)
Sets the reserved word implementation for names (structures names,
class names, etc.).
|
ReservedWordSymbolProvider.Builder |
namespaceReservedWords(ReservedWords namespaceReservedWords)
Sets the reserved word implementation for namespace names.
|
ReservedWordSymbolProvider.Builder |
symbolProvider(SymbolProvider delegate)
Sets the delegate symbol provider.
|
public SymbolProvider build()
SymbolProvider
implementation that wraps another
symbol provider and escapes its results.
This might not always be the right solution. For example,
symbol providers often need to recursively resolve symbols to
create shapes like arrays and maps. In these cases, delegating
would be awkward or impossible since the symbol provider being
wrapped would also need access to the wrapper. In cases like this,
use buildEscaper()
and pass that into the SymbolProvider
directly.
public ReservedWordSymbolProvider.Escaper buildEscaper()
SymbolProvider.Escaper
that is used to manually
escape Symbol
s and member names.public ReservedWordSymbolProvider.Builder symbolProvider(SymbolProvider delegate)
This is only required when calling build()
to build
a SymbolProvider
that delegates to another provider.
delegate
- Symbol provider to delegate to.public ReservedWordSymbolProvider.Builder filenameReservedWords(ReservedWords filenameReservedWords)
If not provided, file names are not passed through a reserved words implementation after calling the delegate.
filenameReservedWords
- Reserved word implementation for namespaces.public ReservedWordSymbolProvider.Builder namespaceReservedWords(ReservedWords namespaceReservedWords)
If not provided, namespace names are not passed through a reserved words implementation after calling the delegate.
namespaceReservedWords
- Reserved word implementation for namespaces.public ReservedWordSymbolProvider.Builder nameReservedWords(ReservedWords nameReservedWords)
If not provided, names are not passed through a reserved words implementation after calling the delegate.
nameReservedWords
- Reserved word implementation for containers.public ReservedWordSymbolProvider.Builder memberReservedWords(ReservedWords memberReservedWords)
If not provided, member names are not passed through a reserved words implementation after calling the delegate.
memberReservedWords
- Reserved word implementation for members.public ReservedWordSymbolProvider.Builder escapePredicate(java.util.function.BiPredicate<Shape,Symbol> escapePredicate)
The predicate is invoked when toSymbol
is called. It
is used to disable/enable escaping reserved words based on the
shape and symbol. The given predicate accepts the Shape
and the Symbol
that was created for the shape and returns
true if reserved word checks should be made or false if reserved
word checks should not be made. For example, some code generators
only escape words that have namespaces to differentiate between
language built-ins and user-defined types.
By default, all symbols are checked for reserved words.
escapePredicate
- Predicate that returns true if escaping should be checked.