Class TraitCodegenUtils
java.lang.Object
software.amazon.smithy.traitcodegen.TraitCodegenUtils
Provides utility methods for trait code generation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Symbolstatic final ReservedWordsstatic final URLstatic final ReservedWords -
Method Summary
Modifier and TypeMethodDescriptionstatic SymbolGets a Smithy codegenSymbolfor a Java class.static StringgetDefaultName(Shape shape) Gets the default class name to use for a given SmithyShape.static StringgetDefaultTraitName(Shape shape) Gets the default class name to use for a given SmithyShapethat defines a trait.static StringgetEnumClassName(Symbol symbol) Gets the proper innerEnumclass name without `Trait` suffix.static booleanisJavaString(Symbol symbol) Checks if a symbol maps to a JavaString.static booleanisJavaStringList(Shape shape, SymbolProvider symbolProvider) Checks if a symbol maps to a JavaList<String>.static booleanisNullableMember(MemberShape shape) Determines if a given member represents a nullable type.static StringmapNamespace(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 codegenSymbolfor 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 SmithyShapethat 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:
-
getEnumClassName
Gets the proper innerEnumclass name without `Trait` suffix.- Parameters:
symbol- the symbol of aEnumShapeorIntEnumShape.- Returns:
- A processed name for
Enumclass.
-