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 ColumnType
Creates aColumnType
for aClass
.static CassandraColumnType
static ColumnType
create
(TypeInformation<?> type) Creates aColumnType
for aTypeInformation
.Returns the component type forCollection
s or the key type forMap
s.Returns the map value type in case the underlying type is aMap
.default ColumnType
Returns the component type forCollection
s, the key type forMap
s or the single generic type if available.default ColumnType
Returns the map value type in case the underlying type is aMap
. or throwIllegalStateException
if the map value type cannot be resolved.Class<?>
getType()
Returns the Java type of the column.boolean
Returns whether the type can be considered a collection, which means it's a container of elements, e.g. aCollection
andArray
or anything implementingIterable
.boolean
isList()
Returns whether the property is aList
.boolean
isMap()
Returns whether the property is aMap
.boolean
isSet()
Returns whether the property is aSet
.static CassandraColumnType
listOf
(CassandraColumnType componentType) Creates a ListColumnType
given itscomponent type
.static CassandraColumnType
listOf
(CassandraColumnType componentType, boolean frozen) Creates a ListColumnType
given itscomponent type
.static ColumnType
listOf
(ColumnType componentType) Creates a ListColumnType
given itscomponent type
.static CassandraColumnType
mapOf
(CassandraColumnType keyType, CassandraColumnType valueType) Creates a MapCassandraColumnType
given itskey and value types
.static CassandraColumnType
mapOf
(CassandraColumnType keyType, CassandraColumnType valueType, boolean frozen) Creates a MapCassandraColumnType
given itskey and value types
.static ColumnType
mapOf
(ColumnType keyType, ColumnType valueType) Creates a MapColumnType
given itskey and value types
.static CassandraColumnType
setOf
(CassandraColumnType componentType) Creates a SetColumnType
given itscomponent type
.static CassandraColumnType
setOf
(CassandraColumnType componentType, boolean frozen) Creates a SetColumnType
given itscomponent type
.static ColumnType
setOf
(ColumnType componentType) Creates a SetColumnType
given itscomponent type
.static CassandraColumnType
tupleOf
(com.datastax.oss.driver.api.core.type.TupleType dataType) Creates a TupleCassandraColumnType
given itsCassandra type
.static CassandraColumnType
udtOf
(com.datastax.oss.driver.api.core.type.UserDefinedType dataType) Creates a UDTCassandraColumnType
given itsCassandra type
.
-
Method Details
-
create
Creates aColumnType
for aClass
.- Parameters:
type
- must not be null.- Returns:
-
create
Creates aColumnType
for 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 ListColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.- Returns:
-
listOf
Creates a ListColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.- Returns:
-
listOf
Creates a ListColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.frozen
-- Returns:
-
setOf
Creates a SetColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.- Returns:
-
setOf
Creates a SetColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.- Returns:
-
setOf
Creates a SetColumnType
given itscomponent type
.- Parameters:
componentType
- must not be null.frozen
-- Returns:
-
mapOf
Creates a MapColumnType
given itskey and value types
.- Parameters:
keyType
- must not be null.valueType
- must not be null.- Returns:
-
mapOf
Creates a MapCassandraColumnType
given 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 MapCassandraColumnType
given itskey and value types
.- Parameters:
keyType
- must not be null.valueType
- must not be null.frozen
-- Returns:
- Since:
- 3.2.4
-
udtOf
Creates a UDTCassandraColumnType
given itsCassandra type
.- Parameters:
dataType
- must not be null.- Returns:
-
tupleOf
Creates a TupleCassandraColumnType
given 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. aCollection
andArray
or 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 forCollection
s or the key type forMap
s.- Returns:
-
getRequiredComponentType
Returns the component type forCollection
s, the key type forMap
s or the single generic type if available. ThrowsIllegalStateException
if 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 throwIllegalStateException
if the map value type cannot be resolved.- Returns:
- Throws:
IllegalStateException
- if the map value type cannot be resolved, usually due to the currentMap
type being a raw one.
-