public interface SymbolProvider
Symbol
objects for shapes.
Implementations of this interface are used to determine what file a shape is defined within, what namespace/module/package a shape is defined in, converts shapes to class/struct/interface names, converts shapes to function/method names, converts shapes to member/property names, and creates variable names from strings.
Method names MUST account for reserved words and the syntax constraints
of the target language. This typically means that implementations will
leverage one or more internal instances of ReservedWords
.
Modifier and Type | Method and Description |
---|---|
static SymbolProvider |
cache(SymbolProvider delegate)
Decorates a
SymbolProvider with a cache and returns the
decorated SymbolProvider . |
default java.lang.String |
toMemberName(MemberShape shape)
Converts a member shape to a member/property name of a containing
data structure.
|
Symbol |
toSymbol(Shape shape)
Gets the symbol to define for the given shape.
|
Symbol toSymbol(Shape shape)
A "symbol" represents the qualified name of a type in a target programming language.
shape
- Shape to get the class name of.default java.lang.String toMemberName(MemberShape shape)
The default implementation will return the member name of the provided shape ID and should be overridden if necessary.
shape
- Shape to convert.static SymbolProvider cache(SymbolProvider delegate)
SymbolProvider
with a cache and returns the
decorated SymbolProvider
.
The results of calling toSymbol
and toMemberName
on delegate
are cached using a thread-safe cache.
SymbolProvider delegate = createComplexProvider(myModel);
SymbolProvider cachingProvider = SymbolProvider.cache(delegate);
delegate
- Symbol provider to wrap and cache its results.