{}
28 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Spring Data Cassandra specific converter infrastructure.
3 | */
4 | @org.jspecify.annotations.NullMarked
5 | package org.springframework.data.cassandra.core.convert;
6 |
7 |
8 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CqlProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql;
17 |
18 | /**
19 | * Interface to be implemented by objects that can provide CQL strings.
20 | *
21 | * Typically implemented by {@link PreparedStatementCreator}s and statement callbacks that want to expose the CQL they
22 | * use to create their statements, to allow for better contextual information in case of exceptions.
23 | *
24 | * @author Mark Paluch
25 | * @since 2.0
26 | * @see PreparedStatementCreator
27 | * @see ReactivePreparedStatementCreator
28 | * @see ReactiveStatementCallback
29 | */
30 | @FunctionalInterface
31 | public interface CqlProvider {
32 |
33 | /**
34 | * Return the CQL string for this object, i.e. typically the CQL used for creating statements.
35 | *
36 | * @return the CQL string.
37 | */
38 | String getCql();
39 | }
40 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/Ordering.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql;
17 |
18 | /**
19 | * Enum for Cassandra primary key column ordering.
20 | *
21 | * @author Matthew T. Adams
22 | * @author Mark Paluch
23 | */
24 | public enum Ordering {
25 |
26 | /**
27 | * Ascending Cassandra column ordering.
28 | */
29 | ASCENDING("ASC"),
30 |
31 | /**
32 | * Descending Cassandra column ordering.
33 | */
34 | DESCENDING("DESC");
35 |
36 | private String cql;
37 |
38 | Ordering(String cql) {
39 | this.cql = cql;
40 | }
41 |
42 | /**
43 | * Returns the CQL keyword of this {@link Ordering}.
44 | */
45 | public String cql() {
46 | return cql;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/PrimaryKeyType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql;
17 |
18 | /**
19 | * Values representing primary key column types.
20 | *
21 | * @author Matthew T. Adams
22 | * @author Alex Shvid
23 | * @author Mark Paluch
24 | */
25 | public enum PrimaryKeyType {
26 |
27 | /**
28 | * Used for a column that is part of the partition key.
29 | */
30 | PARTITIONED,
31 |
32 | /**
33 | * Used for a column that is clustered key.
34 | */
35 | CLUSTERED
36 | }
37 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/converter/AbstractResultSetToBasicFixedTypeConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql.converter;
17 |
18 | import org.springframework.core.convert.ConversionService;
19 | import org.springframework.core.convert.support.DefaultConversionService;
20 |
21 | /**
22 | * Thin wrapper that allows subclasses to delegate conversion of the given value to a {@link DefaultConversionService}.
23 | *
24 | * @author Matthew T. Adams
25 | * @param
26 | */
27 | public abstract class AbstractResultSetToBasicFixedTypeConverter extends AbstractResultSetConverter {
28 |
29 | protected static final ConversionService CONVERTER = DefaultConversionService.getSharedInstance();
30 | }
31 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/converter/ResultSetToDoubleConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql.converter;
17 |
18 | import org.jspecify.annotations.Nullable;
19 |
20 | import org.springframework.core.convert.converter.Converter;
21 |
22 | import com.datastax.oss.driver.api.core.cql.ResultSet;
23 |
24 | /**
25 | * {@link Converter} from {@link ResultSet} to a single {@link Double} value.
26 | *
27 | * @author Mark Paluch
28 | */
29 | public class ResultSetToDoubleConverter extends AbstractResultSetToBasicFixedTypeConverter {
30 |
31 | public static final ResultSetToDoubleConverter INSTANCE = new ResultSetToDoubleConverter();
32 |
33 | @Override
34 | protected @Nullable Double doConvertSingleValue(Object object) {
35 | return CONVERTER.convert(object, Double.class);
36 | }
37 |
38 | @Override
39 | protected Class> getType() {
40 | return Double.class;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/converter/ResultSetToFloatConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql.converter;
17 |
18 | import org.jspecify.annotations.Nullable;
19 |
20 | import org.springframework.core.convert.converter.Converter;
21 |
22 | import com.datastax.oss.driver.api.core.cql.ResultSet;
23 |
24 | /**
25 | * {@link Converter} from {@link ResultSet} to a single {@link Float} value.
26 | *
27 | * @author Mark Paluch
28 | */
29 | public class ResultSetToFloatConverter extends AbstractResultSetToBasicFixedTypeConverter {
30 |
31 | public static final ResultSetToFloatConverter INSTANCE = new ResultSetToFloatConverter();
32 |
33 | @Override
34 | protected @Nullable Float doConvertSingleValue(Object object) {
35 | return CONVERTER.convert(object, Float.class);
36 | }
37 |
38 | @Override
39 | protected Class> getType() {
40 | return Float.class;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/converter/ResultSetToLongConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql.converter;
17 |
18 | import org.jspecify.annotations.Nullable;
19 |
20 | import org.springframework.core.convert.converter.Converter;
21 |
22 | import com.datastax.oss.driver.api.core.cql.ResultSet;
23 |
24 | /**
25 | * {@link Converter} from {@link ResultSet} to a single {@link Long} value.
26 | *
27 | * @author Mark Paluch
28 | */
29 | public class ResultSetToLongConverter extends AbstractResultSetToBasicFixedTypeConverter {
30 |
31 | public static final ResultSetToLongConverter INSTANCE = new ResultSetToLongConverter();
32 |
33 | @Override
34 | protected @Nullable Long doConvertSingleValue(Object object) {
35 | return CONVERTER.convert(object, Long.class);
36 | }
37 |
38 | @Override
39 | protected Class> getType() {
40 | return Long.class;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/converter/RowToArrayConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017-2025 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.springframework.data.cassandra.core.cql.converter;
17 |
18 | import java.util.List;
19 |
20 | import org.springframework.core.convert.converter.Converter;
21 |
22 | import com.datastax.oss.driver.api.core.cql.Row;
23 |
24 | /**
25 | * Converter to convert {@link Row} to {@link Object} array.
26 | *
27 | * @author Mark Paluch
28 | */
29 | public enum RowToArrayConverter implements Converter {
30 |
31 | INSTANCE;
32 |
33 | @Override
34 | public Object[] convert(Row row) {
35 |
36 | List