Interface SymbolProvider
-
- All Known Implementing Classes:
ReservedWordSymbolProvider
,TracingSymbolProvider
public interface SymbolProvider
ProvidesSymbol
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
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static SymbolProvider
cache(SymbolProvider delegate)
Decorates aSymbolProvider
with a cache and returns the decoratedSymbolProvider
.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.
-
-
-
Method Detail
-
toSymbol
Symbol toSymbol(Shape shape)
Gets the symbol to define for the given shape.A "symbol" represents the qualified name of a type in a target programming language.
- When given a structure, union, resource, or service shape, this method should provide the namespace and name of the type to generate.
- When given a simple type like a string, number, or timestamp, this method should return the language-specific type of the shape.
- When given a member shape, this method should return the language specific type to use as the target of the member.
- When given a list, set, or map, this method should return the language specific type to use for the shape (e.g., a map shape for a Python code generator might return "dict".
- Parameters:
shape
- Shape to get the class name of.- Returns:
- Returns the generated class name.
-
toMemberName
default java.lang.String toMemberName(MemberShape shape)
Converts a member shape to a member/property name of a containing data structure.The default implementation will return the member name of the provided shape ID and should be overridden if necessary.
- Parameters:
shape
- Shape to convert.- Returns:
- Returns the converted member name.
-
cache
static SymbolProvider cache(SymbolProvider delegate)
Decorates aSymbolProvider
with a cache and returns the decoratedSymbolProvider
.The results of calling
toSymbol
andtoMemberName
ondelegate
are cached using a thread-safe cache.SymbolProvider delegate = createComplexProvider(myModel); SymbolProvider cachingProvider = SymbolProvider.cache(delegate);
- Parameters:
delegate
- Symbol provider to wrap and cache its results.- Returns:
- Returns the wrapped SymbolProvider.
-
-