Class TraitCodegenUtils
- java.lang.Object
-
- software.amazon.smithy.traitcodegen.TraitCodegenUtils
-
public final class TraitCodegenUtils extends java.lang.Object
Provides utility methods for trait code generation.
-
-
Field Summary
Fields Modifier and Type Field Description static Symbol
JAVA_STRING_SYMBOL
static ReservedWords
MEMBER_ESCAPER
static java.net.URL
RESERVED_WORDS_FILE
static ReservedWords
SHAPE_ESCAPER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Symbol
fromClass(java.lang.Class<?> clazz)
Gets a Smithy codegenSymbol
for a Java class.static java.lang.String
getDefaultName(Shape shape)
Gets the default class name to use for a given SmithyShape
.static java.lang.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 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.
-
-
-
Field Detail
-
JAVA_STRING_SYMBOL
public static final Symbol JAVA_STRING_SYMBOL
-
RESERVED_WORDS_FILE
public static final java.net.URL RESERVED_WORDS_FILE
-
SHAPE_ESCAPER
public static final ReservedWords SHAPE_ESCAPER
-
MEMBER_ESCAPER
public static final ReservedWords MEMBER_ESCAPER
-
-
Method Detail
-
fromClass
public static Symbol fromClass(java.lang.Class<?> clazz)
Gets a Smithy codegenSymbol
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 SmithyShape
.- 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 SmithyShape
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 JavaString
.- 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 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 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 discoveryshapeNamespace
- 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
-
-