diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraColumnType.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraColumnType.java new file mode 100644 index 000000000..b5688d2fe --- /dev/null +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraColumnType.java @@ -0,0 +1,54 @@ +/* + * Copyright 2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.cassandra.core.convert; + +import com.datastax.oss.driver.api.core.type.DataType; +import com.datastax.oss.driver.api.core.type.TupleType; +import com.datastax.oss.driver.api.core.type.UserDefinedType; + +/** + * Descriptor for a Cassandra column type exposing a {@link DataType}. + * + * @author Mark Paluch + * @since 3.0 + */ +public interface CassandraColumnType extends ColumnType { + + /** + * Returns the {@link DataType} associated with this column type. + * + * @return + */ + DataType getDataType(); + + /** + * Returns whether the associated {@link DataType} is a {@link TupleType}. + * + * @return + */ + default boolean isTupleType() { + return getDataType() instanceof TupleType; + } + + /** + * Returns whether the associated {@link DataType} is a {@link UserDefinedType}. + * + * @return + */ + default boolean isUserDefinedType() { + return getDataType() instanceof UserDefinedType; + } +} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraConverter.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraConverter.java index daf6df034..30e037e22 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraConverter.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/CassandraConverter.java @@ -23,6 +23,7 @@ import org.springframework.data.convert.CustomConversions; import org.springframework.data.convert.EntityConverter; import org.springframework.data.util.TypeInformation; import org.springframework.lang.Nullable; +import org.springframework.util.Assert; /** * Central Cassandra specific converter interface from Object to Row. @@ -47,6 +48,15 @@ public interface CassandraConverter @Override CassandraMappingContext getMappingContext(); + /** + * Returns the {@link ColumnTypeResolver} to resolve {@link ColumnType} for properties, {@link TypeInformation}, and + * {@code values}. + * + * @return the {@link ColumnTypeResolver} + * @since 3.0 + */ + ColumnTypeResolver getColumnTypeResolver(); + /** * Returns the Id for an entity. It can return: *