Class TypeConverter
java.lang.Object
io.github.blyznytsiaorg.bibernate.utils.TypeConverter
Contains utility methods for converting Java types to database types and checking compatibility of types for DDL creation.
This utility class provides methods to convert Java types to their corresponding database types and to check if a given Java type
is suitable for creating columns in a database table.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
- See Also:
-
Field Summary
Modifier and TypeFieldDescription -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkIdTypeForGeneration
(Class<?> idFieldType, String tableName) Checks if the ID field type is suitable for ID generation in SQL commands.static String
convertToDatabaseType
(Class<?> columnType) Converts a Java type to its corresponding database type.static String
getPostgresIdTypeForGeneration
(Class<?> idFieldType, String tableName) Gets the Postgres ID type for generation based on the Java ID field type.static boolean
isInternalJavaTypeSuitableForCreation
(EntityColumnDetails entityColumn, String tableName) Checks if the internal Java type is suitable for creating database columns.
-
Field Details
-
typeToDatabaseTypeString
-
-
Constructor Details
-
TypeConverter
public TypeConverter()
-
-
Method Details
-
convertToDatabaseType
Converts a Java type to its corresponding database type.- Parameters:
columnType
- the Java type to convert- Returns:
- the corresponding database type
-
isInternalJavaTypeSuitableForCreation
public static boolean isInternalJavaTypeSuitableForCreation(EntityColumnDetails entityColumn, String tableName) Checks if the internal Java type is suitable for creating database columns. Throws an exception if the type is not supported.- Parameters:
entityColumn
- the details of the entity columntableName
- the name of the table- Returns:
- true if the Java type is suitable, otherwise false
- Throws:
UnsupportedDataTypeException
- if the Java type is not supported
-
getPostgresIdTypeForGeneration
Gets the Postgres ID type for generation based on the Java ID field type.- Parameters:
idFieldType
- the type of the ID fieldtableName
- the name of the table- Returns:
- the Postgres ID type for generation ("serial" or "bigserial")
- Throws:
UnsupportedDataTypeException
- if the ID field type is not supported for generation
-
checkIdTypeForGeneration
Checks if the ID field type is suitable for ID generation in SQL commands.- Parameters:
idFieldType
- the type of the ID fieldtableName
- the name of the table- Throws:
UnsupportedDataTypeException
- if the ID field type is not supported for generation
-