Class TraitCodegenUtils
java.lang.Object
software.amazon.smithy.traitcodegen.TraitCodegenUtils
Provides utility methods for trait code generation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Symbol
static final ReservedWords
static final URL
static final ReservedWords
-
Method Summary
Modifier and TypeMethodDescriptionstatic Symbol
Gets a Smithy codegenSymbol
for a Java class.static String
getDefaultName
(Shape shape) Gets the default class name to use for a given SmithyShape
.static String
getDefaultTraitName
(Shape shape) Gets the default class name to use for a given SmithyShape
that defines a trait.static boolean
isJavaString
(Symbol symbol) Checks if a symbol maps to a JavaString
.static boolean
isJavaStringList
(Shape shape, SymbolProvider symbolProvider) Checks if a symbol maps to a JavaList<String>
.static boolean
isNullableMember
(MemberShape shape) Determines if a given member represents a nullable type.static String
mapNamespace
(String rootSmithyNamespace, String shapeNamespace, String packageNamespace) Maps a smithy namespace to a java package namespace.
-
Field Details
-
JAVA_STRING_SYMBOL
-
RESERVED_WORDS_FILE
-
SHAPE_ESCAPER
-
MEMBER_ESCAPER
-
-
Method Details
-
fromClass
Gets a Smithy codegenSymbol
for a Java class.- Parameters:
clazz
- class to get symbol for.- Returns:
- Symbol representing the provided class.
-
getDefaultName
Gets the default class name to use for a given SmithyShape
.- Parameters:
shape
- Shape to get name for.- Returns:
- Default name.
-
getDefaultTraitName
Gets the default class name to use for a given SmithyShape
that defines a trait.- Parameters:
shape
- Shape to get name for.- Returns:
- Default name.
-
isJavaString
Checks if a symbol maps to a JavaString
.- Parameters:
symbol
- Symbol to check.- Returns:
- Returns true if the symbol maps to a Java String.
-
isJavaStringList
Checks if a symbol maps to a JavaList<String>
.- Parameters:
shape
- shape to check if it resolves to a list of java stringssymbolProvider
- 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 discoveryshapeNamespace
- namespace of shape to map into package namespace.packageNamespace
- Java package namespace for trait codegen.
-
isNullableMember
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:
-