Class ReservedWordSymbolProvider.Builder
- Enclosing class:
- ReservedWordSymbolProvider
ReservedWordSymbolProvider
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds aSymbolProvider
implementation that wraps another symbol provider and escapes its results.Builds aSymbolProvider.Escaper
that is used to manually escapeSymbol
s and member names.escapePredicate
(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.filenameReservedWords
(ReservedWords filenameReservedWords) Sets the reserved word implementation for file names.memberReservedWords
(ReservedWords memberReservedWords) Sets the reserved word implementation for members.nameReservedWords
(ReservedWords nameReservedWords) Sets the reserved word implementation for names (structures names, class names, etc.).namespaceReservedWords
(ReservedWords namespaceReservedWords) Sets the reserved word implementation for namespace names.symbolProvider
(SymbolProvider delegate) Sets the delegate symbol provider.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
build
Builds aSymbolProvider
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.- Returns:
- Returns the built SymbolProvider that delegates to another.
-
buildEscaper
Builds aSymbolProvider.Escaper
that is used to manually escapeSymbol
s and member names.- Returns:
- Returns the built escaper.
-
symbolProvider
Sets the delegate symbol provider.This is only required when calling
build()
to build aSymbolProvider
that delegates to another provider.- Parameters:
delegate
- Symbol provider to delegate to.- Returns:
- Returns the builder
-
filenameReservedWords
public ReservedWordSymbolProvider.Builder filenameReservedWords(ReservedWords filenameReservedWords) Sets the reserved word implementation for file names.If not provided, file names are not passed through a reserved words implementation after calling the delegate.
- Parameters:
filenameReservedWords
- Reserved word implementation for namespaces.- Returns:
- Returns the builder.
-
namespaceReservedWords
public ReservedWordSymbolProvider.Builder namespaceReservedWords(ReservedWords namespaceReservedWords) Sets the reserved word implementation for namespace names.If not provided, namespace names are not passed through a reserved words implementation after calling the delegate.
- Parameters:
namespaceReservedWords
- Reserved word implementation for namespaces.- Returns:
- Returns the builder.
-
nameReservedWords
Sets the reserved word implementation for names (structures names, class names, etc.).If not provided, names are not passed through a reserved words implementation after calling the delegate.
- Parameters:
nameReservedWords
- Reserved word implementation for containers.- Returns:
- Returns the builder.
-
memberReservedWords
Sets the reserved word implementation for members.If not provided, member names are not passed through a reserved words implementation after calling the delegate.
- Parameters:
memberReservedWords
- Reserved word implementation for members.- Returns:
- Returns the builder.
-
escapePredicate
public ReservedWordSymbolProvider.Builder escapePredicate(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.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 theShape
and theSymbol
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.
- Parameters:
escapePredicate
- Predicate that returns true if escaping should be checked.- Returns:
- Returns the builder.
-