Class TraitCodegenUtils

java.lang.Object
software.amazon.smithy.traitcodegen.TraitCodegenUtils

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

    • JAVA_STRING_SYMBOL

      public static final Symbol JAVA_STRING_SYMBOL
    • RESERVED_WORDS_FILE

      public static final URL RESERVED_WORDS_FILE
    • SHAPE_ESCAPER

      public static final ReservedWords SHAPE_ESCAPER
    • MEMBER_ESCAPER

      public static final ReservedWords MEMBER_ESCAPER
  • Method Details

    • fromClass

      public static Symbol fromClass(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 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 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 String mapNamespace(String rootSmithyNamespace, String shapeNamespace, 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: