Class TraitCodegenUtils


  • public final class TraitCodegenUtils
    extends java.lang.Object
    Provides utility methods for trait code generation.
    • Field Detail

      • JAVA_STRING_SYMBOL

        public static final Symbol JAVA_STRING_SYMBOL
      • RESERVED_WORDS_FILE

        public static final java.net.URL RESERVED_WORDS_FILE
      • MEMBER_ESCAPER

        public static final ReservedWords MEMBER_ESCAPER
    • Method Detail

      • fromClass

        public static Symbol fromClass​(java.lang.Class<?> clazz)
        Gets a Smithy codegen Symbol for a Java class.
        Parameters:
        clazz - class to get symbol for.
        Returns:
        Symbol representing the provided class.
      • getDefaultName

        public static java.lang.String getDefaultName​(Shape shape)
        Gets the default class name to use for a given Smithy Shape.
        Parameters:
        shape - Shape to get name for.
        Returns:
        Default name.
      • getDefaultTraitName

        public static java.lang.String getDefaultTraitName​(Shape shape)
        Gets the default class name to use for a given Smithy Shape that defines a trait.
        Parameters:
        shape - Shape to get name for.
        Returns:
        Default name.
      • isJavaString

        public static boolean isJavaString​(Symbol symbol)
        Checks if a symbol maps to a Java String.
        Parameters:
        symbol - Symbol to check.
        Returns:
        Returns true if the symbol maps to a Java String.
      • isJavaStringList

        public static boolean isJavaStringList​(Shape shape,
                                               SymbolProvider symbolProvider)
        Checks if a symbol maps to a Java List<String>.
        Parameters:
        shape - shape to check if it resolves to a list of java strings
        symbolProvider - symbol provider to use for checking member type
        Returns:
        Returns true if the symbol maps to a Java String List.
      • mapNamespace

        public static java.lang.String mapNamespace​(java.lang.String rootSmithyNamespace,
                                                    java.lang.String shapeNamespace,
                                                    java.lang.String packageNamespace)
        Maps a smithy namespace to a java package namespace.
        Parameters:
        rootSmithyNamespace - base smithy namespace in use for trait codegen trait discovery
        shapeNamespace - namespace of shape to map into package namespace.
        packageNamespace - Java package namespace for trait codegen.
      • isNullableMember

        public static boolean isNullableMember​(MemberShape shape)
        Determines if a given member represents a nullable type.
        Parameters:
        shape - member to check for nullability
        Returns:
        if the shape is a nullable type
        See Also:
        structure member optionality