Interface SymbolProvider

  • All Known Implementing Classes:
    ReservedWordSymbolProvider

    public interface SymbolProvider
    Provides 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.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.lang.String toMemberName​(software.amazon.smithy.model.shapes.Shape shape)
      Converts a shape to a member/property name of a containing data structure.
      Symbol toSymbol​(software.amazon.smithy.model.shapes.Shape shape)
      Gets the symbol to define for the given shape.
    • Method Detail

      • toSymbol

        Symbol toSymbol​(software.amazon.smithy.model.shapes.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​(software.amazon.smithy.model.shapes.Shape shape)
        Converts a shape to a member/property name of a containing data structure.

        The default implementation will return the member name of the provided shape ID if the shape ID contains a member. If no member is present, the name of the shape with the first letter converted to lowercase is returned. The default implementation may not work for all use cases and should be overridden as needed.

        Parameters:
        shape - Shape to convert.
        Returns:
        Returns the converted member name.