Interface ColumnType
- All Known Subinterfaces:
CassandraColumnType
public interface ColumnType
Interface to access column type information. The
CassandraColumnType subtype exposes Cassandra-specific
DataType information.- Since:
- 3.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionstatic ColumnTypeCreates aColumnTypefor aClass.static CassandraColumnTypestatic ColumnTypecreate(TypeInformation<?> type) Creates aColumnTypefor aTypeInformation.Returns the component type forCollections or the key type forMaps.Returns the map value type in case the underlying type is aMap.default ColumnTypeReturns the component type forCollections, the key type forMaps or the single generic type if available.default ColumnTypeReturns the map value type in case the underlying type is aMap. or throwIllegalStateExceptionif the map value type cannot be resolved.Class<?>getType()Returns the Java type of the column.booleanReturns whether the type can be considered a collection, which means it's a container of elements, e.g. aCollectionandArrayor anything implementingIterable.booleanisList()Returns whether the property is aList.booleanisMap()Returns whether the property is aMap.booleanisSet()Returns whether the property is aSet.static CassandraColumnTypelistOf(CassandraColumnType componentType) Creates a ListColumnTypegiven itscomponent type.static CassandraColumnTypelistOf(CassandraColumnType componentType, boolean frozen) Creates a ListColumnTypegiven itscomponent type.static ColumnTypelistOf(ColumnType componentType) Creates a ListColumnTypegiven itscomponent type.static CassandraColumnTypemapOf(CassandraColumnType keyType, CassandraColumnType valueType) Creates a MapCassandraColumnTypegiven itskey and value types.static CassandraColumnTypemapOf(CassandraColumnType keyType, CassandraColumnType valueType, boolean frozen) Creates a MapCassandraColumnTypegiven itskey and value types.static ColumnTypemapOf(ColumnType keyType, ColumnType valueType) Creates a MapColumnTypegiven itskey and value types.static CassandraColumnTypesetOf(CassandraColumnType componentType) Creates a SetColumnTypegiven itscomponent type.static CassandraColumnTypesetOf(CassandraColumnType componentType, boolean frozen) Creates a SetColumnTypegiven itscomponent type.static ColumnTypesetOf(ColumnType componentType) Creates a SetColumnTypegiven itscomponent type.static CassandraColumnTypetupleOf(com.datastax.oss.driver.api.core.type.TupleType dataType) Creates a TupleCassandraColumnTypegiven itsCassandra type.static CassandraColumnTypeudtOf(com.datastax.oss.driver.api.core.type.UserDefinedType dataType) Creates a UDTCassandraColumnTypegiven itsCassandra type.
-
Method Details
-
create
Creates aColumnTypefor aClass.- Parameters:
type- must not be null.- Returns:
-
create
Creates aColumnTypefor aTypeInformation.- Parameters:
type- must not be null.- Returns:
-
create
static CassandraColumnType create(Class<?> type, com.datastax.oss.driver.api.core.type.DataType dataType) - Parameters:
type- must not be null.dataType- must not be null.- Returns:
-
listOf
Creates a ListColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.- Returns:
-
listOf
Creates a ListColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.- Returns:
-
listOf
Creates a ListColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.frozen-- Returns:
-
setOf
Creates a SetColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.- Returns:
-
setOf
Creates a SetColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.- Returns:
-
setOf
Creates a SetColumnTypegiven itscomponent type.- Parameters:
componentType- must not be null.frozen-- Returns:
-
mapOf
Creates a MapColumnTypegiven itskey and value types.- Parameters:
keyType- must not be null.valueType- must not be null.- Returns:
-
mapOf
Creates a MapCassandraColumnTypegiven itskey and value types.- Parameters:
keyType- must not be null.valueType- must not be null.- Returns:
-
mapOf
static CassandraColumnType mapOf(CassandraColumnType keyType, CassandraColumnType valueType, boolean frozen) Creates a MapCassandraColumnTypegiven itskey and value types.- Parameters:
keyType- must not be null.valueType- must not be null.frozen-- Returns:
- Since:
- 3.2.4
-
udtOf
Creates a UDTCassandraColumnTypegiven itsCassandra type.- Parameters:
dataType- must not be null.- Returns:
-
tupleOf
Creates a TupleCassandraColumnTypegiven itsCassandra type.- Parameters:
dataType- must not be null.- Returns:
-
getType
Class<?> getType()Returns the Java type of the column.- Returns:
-
isCollectionLike
boolean isCollectionLike()Returns whether the type can be considered a collection, which means it's a container of elements, e.g. aCollectionandArrayor anything implementingIterable. If this returns true you can expectgetComponentType()to return a non-null value.- Returns:
-
isList
boolean isList()Returns whether the property is aList. If this returns true you can expectgetComponentType()to return something not null.- Returns:
-
isSet
boolean isSet()Returns whether the property is aSet. If this returns true you can expectgetComponentType()to return something not null.- Returns:
-
isMap
boolean isMap()Returns whether the property is aMap. If this returns true you can expectgetComponentType()as well asgetMapValueType()to return something not null.- Returns:
-
getComponentType
Returns the component type forCollections or the key type forMaps.- Returns:
-
getRequiredComponentType
Returns the component type forCollections, the key type forMaps or the single generic type if available. ThrowsIllegalStateExceptionif the component value type cannot be resolved.- Returns:
- Throws:
IllegalStateException- if the component type cannot be resolved, e.g. if a raw type is used or the type is not generic in the first place.
-
getMapValueType
Returns the map value type in case the underlying type is aMap.- Returns:
-
getRequiredMapValueType
Returns the map value type in case the underlying type is aMap. or throwIllegalStateExceptionif the map value type cannot be resolved.- Returns:
- Throws:
IllegalStateException- if the map value type cannot be resolved, usually due to the currentMaptype being a raw one.
-