Class ColumnTypeMapper
java.lang.Object
com.datastax.astra.client.tables.definition.columns.ColumnTypeMapper
Maps Java types to corresponding Cassandra column types.
The ColumnTypeMapper provides a utility method to determine the appropriate
Cassandra column type for a given Java class. Commonly used Java types, such as
primitives, wrapper types, collections, and date/time classes, are mapped to their
respective Cassandra types.
Example usage:
ColumnTypes columnType = ColumnTypeMapper.getColumnType(String.class);
System.out.println(columnType); // Outputs: TEXT
Supported mappings include:
- Primitives and wrappers (e.g.,
int -> INT,boolean -> BOOLEAN) - Common Java types (e.g.,
String -> TEXT,UUID -> UUID) - Date and time types (e.g.,
LocalDate -> DATE,Instant -> TIMESTAMP) - Collection types (e.g.,
List -> LIST,Set -> SET,Map -> MAP) - Default fallback for unsupported types:
UNSUPPORTED
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColumnTypesgetColumnType(Class<?> clazz) Retrieves the Cassandra column type corresponding to the given Java class.
-
Method Details
-
getColumnType
Retrieves the Cassandra column type corresponding to the given Java class. If the type is not explicitly mapped,ColumnTypes.UNSUPPORTEDis returned.- Parameters:
clazz- the Java class to map- Returns:
- the corresponding
ColumnTypes, orUNSUPPORTEDif the type is not mapped
-