Class Utils
- java.lang.Object
-
- software.amazon.awssdk.codegen.internal.Utils
-
public final class Utils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
capitalize(String name)
static void
closeQuietly(Closeable closeable)
static void
createDirectory(File dir)
static File
createDirectory(String path)
static File
createFile(String dir, String fileName)
static ShapeMarshaller
createInputShapeMarshaller(ServiceMetadata service, Operation operation)
Create the ShapeMarshaller to the input shape from the specified Operation.static String
directoryToPackage(String directoryPath)
Converts a directory to a Java package name.static ShapeModel
findMemberShapeModelByC2jNameIfExists(IntermediateModel intermediateModel, String shapeC2jName)
Search for a shape model by its C2J name, excluding request and response shapes, which are not candidates to be members of another shape.static ShapeModel
findShapeModelByC2jName(IntermediateModel intermediateModel, String shapeC2jName)
Search for intermediate shape model by its c2j name.static ShapeModel
findShapeModelByC2jNameIfExists(IntermediateModel intermediateModel, String shapeC2jName)
Search for intermediate shape model by its c2j name.static List<ShapeModel>
findShapesByC2jName(IntermediateModel intermediateModel, String shapeC2jName)
static String
getDefaultEndpointWithoutHttpProtocol(String endpoint)
static String
getFileNamePrefix(ServiceModel serviceModel)
* @param serviceModel Service model to get prefix for.static InputStream
getRequiredResourceAsStream(Class<?> clzz, String location)
Return an InputStream of the specified resource, failing if it can't be found.static boolean
isEnumShape(Shape shape)
static boolean
isExceptionShape(Shape shape)
static boolean
isListShape(Shape shape)
static boolean
isListWithEnumShape(MemberModel member)
static boolean
isMapKeyWithEnumShape(MapModel mapModel)
static boolean
isMapShape(Shape shape)
static boolean
isMapValueWithEnumShape(MapModel mapModel)
static boolean
isMapWithEnumShape(MemberModel member)
static boolean
isNullOrEmpty(String str)
static boolean
isOrContainsEnum(MemberModel member)
static boolean
isOrContainsEnumShape(Shape shape, Map<String,Shape> allShapes)
static boolean
isScalar(Shape shape)
static boolean
isStructure(Shape shape)
static String
packageToDirectory(String packageName)
Converts a Java package name to a directory.static String
removeLeading(String str, String toRemove)
static String
removeTrailing(String str, String toRemove)
static String
unCapitalize(String name)
-
-
-
Method Detail
-
isScalar
public static boolean isScalar(Shape shape)
-
isStructure
public static boolean isStructure(Shape shape)
-
isListShape
public static boolean isListShape(Shape shape)
-
isMapShape
public static boolean isMapShape(Shape shape)
-
isEnumShape
public static boolean isEnumShape(Shape shape)
-
isExceptionShape
public static boolean isExceptionShape(Shape shape)
-
isOrContainsEnumShape
public static boolean isOrContainsEnumShape(Shape shape, Map<String,Shape> allShapes)
-
isOrContainsEnum
public static boolean isOrContainsEnum(MemberModel member)
-
isListWithEnumShape
public static boolean isListWithEnumShape(MemberModel member)
-
isMapWithEnumShape
public static boolean isMapWithEnumShape(MemberModel member)
-
isMapKeyWithEnumShape
public static boolean isMapKeyWithEnumShape(MapModel mapModel)
-
isMapValueWithEnumShape
public static boolean isMapValueWithEnumShape(MapModel mapModel)
-
getFileNamePrefix
public static String getFileNamePrefix(ServiceModel serviceModel)
* @param serviceModel Service model to get prefix for. * @return Prefix to use when writing model files (service and intermediate).
-
directoryToPackage
public static String directoryToPackage(String directoryPath)
Converts a directory to a Java package name.- Parameters:
directoryPath
- Directory to convert.- Returns:
- Package name
-
packageToDirectory
public static String packageToDirectory(String packageName)
Converts a Java package name to a directory.- Parameters:
packageName
- Java package to convert.- Returns:
- directory
-
getDefaultEndpointWithoutHttpProtocol
public static String getDefaultEndpointWithoutHttpProtocol(String endpoint)
-
createDirectory
public static void createDirectory(File dir)
-
createFile
public static File createFile(String dir, String fileName) throws IOException
- Throws:
IOException
-
isNullOrEmpty
public static boolean isNullOrEmpty(String str)
-
closeQuietly
public static void closeQuietly(Closeable closeable)
-
getRequiredResourceAsStream
public static InputStream getRequiredResourceAsStream(Class<?> clzz, String location)
Return an InputStream of the specified resource, failing if it can't be found.- Parameters:
location
- Location of resource
-
findShapeModelByC2jName
public static ShapeModel findShapeModelByC2jName(IntermediateModel intermediateModel, String shapeC2jName) throws IllegalArgumentException
Search for intermediate shape model by its c2j name.- Returns:
- ShapeModel
- Throws:
IllegalArgumentException
- if the specified c2j name is not found in the intermediate model.
-
findShapeModelByC2jNameIfExists
public static ShapeModel findShapeModelByC2jNameIfExists(IntermediateModel intermediateModel, String shapeC2jName)
Search for intermediate shape model by its c2j name.- Returns:
- ShapeModel or null if the shape doesn't exist (if it's primitive or container type for example)
-
findMemberShapeModelByC2jNameIfExists
public static ShapeModel findMemberShapeModelByC2jNameIfExists(IntermediateModel intermediateModel, String shapeC2jName)
Search for a shape model by its C2J name, excluding request and response shapes, which are not candidates to be members of another shape.- Returns:
- ShapeModel or null if the shape doesn't exist (if it's primitive or container type for example)
-
findShapesByC2jName
public static List<ShapeModel> findShapesByC2jName(IntermediateModel intermediateModel, String shapeC2jName)
-
createInputShapeMarshaller
public static ShapeMarshaller createInputShapeMarshaller(ServiceMetadata service, Operation operation)
Create the ShapeMarshaller to the input shape from the specified Operation. The input shape in the operation could be empty.
-
-