diff --git a/spring-cql/src/main/java/org/springframework/cassandra/config/MultiLevelListFlattenerFactoryBean.java b/spring-cql/src/main/java/org/springframework/cassandra/config/MultiLevelListFlattenerFactoryBean.java deleted file mode 100644 index 504143c1a..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/config/MultiLevelListFlattenerFactoryBean.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2013-2017 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 - * - * http://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.cassandra.config; - -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.FactoryBean; - -/** - * Given List of Lists where all child Lists contain the same class, then a single level List of is generated. - * - * @author David Webb - * @param - */ -public class MultiLevelListFlattenerFactoryBean implements FactoryBean> { - - private List> multiLevelList; - - @Override - public List getObject() throws Exception { - return multiLevelList.stream().flatMap(Collection::stream).collect(Collectors.toList()); - } - - @Override - public Class getObjectType() { - return List.class; - } - - @Override - public boolean isSingleton() { - return true; - } - - /** - * @return Returns the multiLevelList. - */ - public List> getMultiLevelList() { - return multiLevelList; - } - - /** - * @param multiLevelList The multiLevelList to set. - */ - public void setMultiLevelList(List> multiLevelList) { - this.multiLevelList = multiLevelList; - } - -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/Cancellable.java b/spring-cql/src/main/java/org/springframework/cassandra/core/Cancellable.java deleted file mode 100644 index b599c3ed3..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/Cancellable.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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.cassandra.core; - -/** - * Interface allowing a caller to cancel an asynchronous query. - * - * @author Matthew T. Adams - */ -public interface Cancellable { - - /** - * Cancels the query operation that this cancellable came from. - */ - void cancel(); -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListListener.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListListener.java deleted file mode 100644 index 11e88154f..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017 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 - * - * http://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.cassandra.core; - -import java.util.List; - -import com.datastax.driver.core.ResultSet; - -/** - * Listener used to receive asynchronous results expected as a {@code List}. - * - * @author Matthew T. Adams - * @param - */ -public interface QueryForListListener { - - /** - * Called upon query completion. - */ - void onQueryComplete(List results); - - /** - * Called if an exception is raised while getting or converting the {@link ResultSet}. - */ - void onException(Exception x); -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListOfMapListener.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListOfMapListener.java deleted file mode 100644 index 242fcbef2..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForListOfMapListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2017 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 - * - * http://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.cassandra.core; - -import java.util.Map; - -/** - * Listener used to receive asynchronous results expected as a {@code List}. - * - * @author Matthew T. Adams - */ -public interface QueryForListOfMapListener extends QueryForListListener> {} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForMapListener.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForMapListener.java deleted file mode 100644 index 953997b28..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForMapListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017 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 - * - * http://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.cassandra.core; - -import java.util.Map; - -import com.datastax.driver.core.ResultSet; - -/** - * Listener used to receive asynchronous results expected as a {@code List>}. - * - * @author Matthew T. Adams - * @param - */ -public interface QueryForMapListener { - - /** - * Called upon query completion. - */ - void onQueryComplete(Map results); - - /** - * Called if an exception is raised while getting or converting the {@link ResultSet}. - */ - void onException(Exception x); -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForObjectListener.java b/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForObjectListener.java deleted file mode 100644 index f1f4da2d4..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/QueryForObjectListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016-2017 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 - * - * http://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.cassandra.core; - -import com.datastax.driver.core.ResultSet; - -/** - * Listener used to receive asynchronous results expected as an object of type {@code T} or an {@link Exception}. - * - * @author Matthew T. Adams - * @author Mark Paluch - * @param - */ -public interface QueryForObjectListener { - - /** - * Called upon query completion. - * - * @param result the result, can be {@literal null} for empty single-record results. - */ - void onQueryComplete(T result); - - /** - * Called if an exception is raised while getting or converting the {@link ResultSet}. - * - * @param ex the exception that triggered the failure, never {@link null}. - */ - void onException(Exception ex); -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/ResultSetFutureExtractor.java b/spring-cql/src/main/java/org/springframework/cassandra/core/ResultSetFutureExtractor.java deleted file mode 100644 index dd1523f6b..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/ResultSetFutureExtractor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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.cassandra.core; - -import org.springframework.dao.DataAccessException; - -import com.datastax.driver.core.ResultSetFuture; -import com.datastax.driver.core.exceptions.DriverException; - -/** - * @param - * @deprecated as of 2.0, not used anymore. - */ -public interface ResultSetFutureExtractor { - - T extractData(ResultSetFuture rs) throws DriverException, DataAccessException; -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallback.java b/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallback.java deleted file mode 100644 index 8a5426fac..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/RowCallback.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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.cassandra.core; - -import com.datastax.driver.core.Row; - -/** - * Simple internal callback to allow operations on a {@link Row}. - * - * @author Alex Shvid - * @deprecated as of 2.0. Superseded by {@link RowCallbackHandler}. - */ -public interface RowCallback { - - /** - * Implementations must implement this method to process each row of data in the - * {@link com.datastax.driver.core.ResultSet}. This method is only supposed to extract values of the current row. - * - * @param object - * @return - */ - T doWith(Row object); -} diff --git a/spring-cql/src/main/java/org/springframework/cassandra/core/RowIterator.java b/spring-cql/src/main/java/org/springframework/cassandra/core/RowIterator.java deleted file mode 100644 index c05b64eae..000000000 --- a/spring-cql/src/main/java/org/springframework/cassandra/core/RowIterator.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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.cassandra.core; - -/** - * @author David Webb - * @deprecated as of 2.0. This class is not used anymore. - */ -@Deprecated -public interface RowIterator { - - Object[] next(); - - boolean hasNext(); - -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java index 1a60ccbcf..66ebd6366 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/config/BeanDefinitionUtils.java @@ -22,9 +22,7 @@ import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinitionHolder; -import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionRegistry; -import org.springframework.util.StringUtils; /** * Utilities to lookup {@link BeanDefinition bean definitions} for a {@link ListableBeanFactory} and to conditionally @@ -32,89 +30,8 @@ import org.springframework.util.StringUtils; * * @author Matthew Adams * @author Mark Paluch - * @deprecated Will be removed with the next major release. */ -@Deprecated -public class BeanDefinitionUtils { - - /** - * Returns a {@link BeanDefinitionBuilder} iff no {@link BeanDefinition} of the required type is found in the given - * {@link ListableBeanFactory}, otherwise returns {@code null}, indicating that at least one existed. - * - * @param factory The {@link ListableBeanFactory} in which to look for the {@link BeanDefinition}, including - * ancestors. - * @param requiredType The {@link BeanDefinition}'s required type. - * @param instantiableType The instantiable type for the {@link BeanDefinitionBuilder}. - * @param constructorArgs Any {@link BeanDefinitionBuilderArgument}s required by the instantiableType's constructor. - * @return A {@link BeanDefinitionBuilder} iff no {@link BeanDefinition} of the required type is found, otherwise - * {@code null}. - * @see BeanDefinitionUtils#createBeanDefinitionBuilderIfNoBeanDefinitionOfTypeExists(ListableBeanFactory, Class, - * Class, BeanDefinitionBuilderArgument...) - * @see BeanDefinitionBuilderArgument#ref(Object) - * @see BeanDefinitionBuilderArgument#val(Object) - */ - public static BeanDefinitionBuilder createBeanDefinitionBuilderIfNoBeanDefinitionOfTypeExists( - ListableBeanFactory factory, Class requiredType, Class instantiableType, - BeanDefinitionBuilderArgument... constructorArgs) { - - String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, requiredType, true, false); - if (names.length > 0) { - return null; - } - - BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(instantiableType); - if (constructorArgs == null) { - return builder; - } - - for (BeanDefinitionBuilderArgument arg : constructorArgs) { - if (arg.reference) { - builder.addConstructorArgReference(arg.value.toString()); - } else { - builder.addConstructorArgValue(arg.value); - } - } - - return builder; - } - - /** - * Returns the single {@link BeanDefinitionHolder} with the given type, or null of none were found and - * {@code required} was false, otherwise throws {@link IllegalArgumentException}. - * - * @param registry The {@link BeanDefinitionRegistry}, often the very same instance as the {@code factor} parameter. - * @param factory The {@link ListableBeanFactory}, often the very same instance as the {@code registry} parameter. - * @param type The required {@link BeanDefinition}'s type. - * @param includeNonSingletons Whether to include beans with scope other than {@code singleton} - * @param allowEagerInit Whether to allow eager initialization of beans. - * @param required Whether to allow the return of null if none were found. - * @return The {@link BeanDefinitionHolder} or null if none found, depending on the value of {@code required}. - * @throws IllegalArgumentException If multiple were found. - * @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean) - */ - public static BeanDefinitionHolder getSingleBeanDefinitionOfType(BeanDefinitionRegistry registry, - ListableBeanFactory factory, Class type, boolean includeNonSingletons, boolean allowEagerInit, - boolean required) { - - BeanDefinitionHolder[] definitions = getBeanDefinitionsOfType(registry, factory, type, includeNonSingletons, - allowEagerInit); - - if (definitions.length == 1) { - return definitions[0]; - } - - if (definitions.length == 0 && !required) { - return null; - } - - String[] names = new String[definitions.length]; - for (int i = 0; i < names.length; i++) { - names[i] = definitions[i].getBeanName(); - } - - throw new IllegalStateException(String.format("expected one bean definition of type [%s], but found %d: %s", - type.getName(), definitions.length, StringUtils.arrayToCommaDelimitedString(names))); - } +class BeanDefinitionUtils { /** * Returns all {@link BeanDefinitionHolder}s with the given type. @@ -128,8 +45,8 @@ public class BeanDefinitionUtils { * @return The {@link BeanDefinitionHolder}s -- never returns null. * @see BeanFactoryUtils#beanNamesForTypeIncludingAncestors(ListableBeanFactory, Class, boolean, boolean) */ - public static BeanDefinitionHolder[] getBeanDefinitionsOfType(BeanDefinitionRegistry registry, - ListableBeanFactory factory, Class type, boolean includeNonSingletons, boolean allowEagerInit) { + static BeanDefinitionHolder[] getBeanDefinitionsOfType(BeanDefinitionRegistry registry, ListableBeanFactory factory, + Class type, boolean includeNonSingletons, boolean allowEagerInit) { String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, type, includeNonSingletons, allowEagerInit); diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/MappingCassandraConverter.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/MappingCassandraConverter.java index 22e59b578..d008bc57c 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/MappingCassandraConverter.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/convert/MappingCassandraConverter.java @@ -203,17 +203,6 @@ public class MappingCassandraConverter extends AbstractCassandraConverter property -> MappingCassandraConverter.this.readProperty(entity, property, valueProvider, propertyAccessor)); } - /** - * @deprecated Use - * {@link #readProperty(CassandraPersistentEntity, CassandraPersistentProperty, CassandraValueProvider, PersistentPropertyAccessor)} - */ - @Deprecated - protected void readPropertyFromRow(CassandraPersistentEntity entity, CassandraPersistentProperty property, - CassandraRowValueProvider valueProvider, PersistentPropertyAccessor propertyAccessor) { - - readProperty(entity, property, valueProvider, propertyAccessor); - } - protected void readProperty(CassandraPersistentEntity entity, CassandraPersistentProperty property, CassandraValueProvider valueProvider, PersistentPropertyAccessor propertyAccessor) { diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraConverterRowCallback.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraConverterRowCallback.java deleted file mode 100644 index e17802c78..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraConverterRowCallback.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013-2017 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 - * - * http://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; - -import org.springframework.cassandra.core.RowCallback; -import org.springframework.data.cassandra.convert.CassandraConverter; -import org.springframework.util.Assert; - -import com.datastax.driver.core.Row; - -/** - * Simple {@link RowCallback} that will transform a {@link Row} into the given target type using the given - * {@link CassandraConverter}. - * - * @author Alex Shvid - * @author Matthew T. Adams - * @author Mark Paluch - */ -public class CassandraConverterRowCallback implements RowCallback { - - private final CassandraConverter reader; - - private final Class type; - - /** - * Create a new {@link CassandraConverterRowCallback} instance given {@link CassandraConverter} and a target - * {@link Class type}. - * - * @param reader must not be {@literal null}. - * @param type must not be {@literal null}. - */ - public CassandraConverterRowCallback(CassandraConverter reader, Class type) { - - Assert.notNull(reader, "CassandraConverter must not be null"); - Assert.notNull(type, "Target class must not be null"); - - this.reader = reader; - this.type = type; - } - - /* (non-Javadoc) - * @see org.springframework.cassandra.core.RowCallback#doWith(com.datastax.driver.core.Row) - */ - @Override - public T doWith(Row row) { - return reader.read(type, row); - } -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraValue.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraValue.java deleted file mode 100644 index 450d133a7..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/CassandraValue.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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; - -import java.nio.ByteBuffer; - -import com.datastax.driver.core.DataType; - -/** - * Simple Cassandra value of the ByteBuffer with DataType - * - * @author Alex Shvid - * @deprecated as of 2.0, not used anymore. - */ -@Deprecated -public class CassandraValue { - - private final ByteBuffer value; - private final DataType type; - - public CassandraValue(ByteBuffer value, DataType type) { - this.value = value; - this.type = type; - } - - public ByteBuffer getValue() { - return value; - } - - public DataType getType() { - return type; - } - -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/DeletionListener.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/DeletionListener.java deleted file mode 100644 index 8c9097218..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/DeletionListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.springframework.data.cassandra.core; - -import java.util.Collection; - -import com.datastax.driver.core.ResultSet; - -/** - * Listener for asynchronous repository insert or update methods. - * - * @author Matthew T. Adams - * @author Mark Paluch - * @deprecated as of 2.0, not used anymore. - */ -@Deprecated -public interface DeletionListener { - - void onDeletionComplete(Collection entities); - - /** - * Called if an exception is raised while getting or converting the {@link ResultSet}. - */ - void onException(Exception x); -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/WriteListener.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/WriteListener.java deleted file mode 100644 index a1a03404c..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/WriteListener.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2013-2014 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 - * - * http://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; - -import java.util.Collection; - -import com.datastax.driver.core.ResultSet; - -/** - * Listener for asynchronous repository insert or update methods. - * - * @author Matthew T. Adams - * @deprecated as of 2.0, not used anymore. - */ -@Deprecated -public interface WriteListener { - - /** - * Called upon completion of the asynchronous insert or update. - * - * @param entities The entities inserted or updated. - */ - void onWriteComplete(Collection entities); - - /** - * Called if an exception is raised while getting or converting the {@link ResultSet}. - */ - void onException(Exception x); -} diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/AbstractCassandraQuery.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/AbstractCassandraQuery.java index 765be3b85..ed63f9365 100644 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/AbstractCassandraQuery.java +++ b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/AbstractCassandraQuery.java @@ -17,20 +17,11 @@ package org.springframework.data.cassandra.repository.query; import lombok.RequiredArgsConstructor; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.converter.Converter; -import org.springframework.data.cassandra.convert.CassandraConverter; import org.springframework.data.cassandra.core.CassandraOperations; import org.springframework.data.cassandra.repository.query.CassandraQueryExecution.CollectionExecution; import org.springframework.data.cassandra.repository.query.CassandraQueryExecution.ResultProcessingConverter; @@ -47,9 +38,6 @@ import org.springframework.data.repository.query.ReturnedType; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; -import com.datastax.driver.core.ResultSet; -import com.datastax.driver.core.Row; - /** * Base class for {@link RepositoryQuery} implementations for Cassandra. * @@ -142,101 +130,6 @@ public abstract class AbstractCassandraQuery implements RepositoryQuery { } } - /** - * @param resultSet - * @param declaredReturnType - * @param returnedUnwrappedObjectType - * @return - * @deprecated as of 1.5, {@link org.springframework.data.cassandra.mapping.CassandraMappingContext} handles type - * conversion. - */ - @Deprecated - public Object getCollectionOfEntity(ResultSet resultSet, Class declaredReturnType, - Class returnedUnwrappedObjectType) { - - Collection results; - - if (ClassUtils.isAssignable(SortedSet.class, declaredReturnType)) { - results = new TreeSet<>(); - } else if (ClassUtils.isAssignable(Set.class, declaredReturnType)) { - results = new HashSet<>(); - } else { // List.class, Collection.class, or array - results = new ArrayList<>(); - } - - CassandraConverter converter = template.getConverter(); - - for (Row row : resultSet) { - results.add(converter.read(returnedUnwrappedObjectType, row)); - } - - return results; - } - - /** - * @param resultSet - * @param type - * @return - * @deprecated as of 1.5, {@link org.springframework.data.cassandra.mapping.CassandraMappingContext} handles type - * conversion. - */ - @Deprecated - public Object getSingleEntity(ResultSet resultSet, Class type) { - - Object result = (resultSet.isExhausted() ? null : template.getConverter().read(type, resultSet.one())); - - warnIfMoreResults(resultSet); - - return result; - } - - private void warnIfMoreResults(ResultSet resultSet) { - - if (log.isWarnEnabled() && !resultSet.isExhausted()) { - int count = 0; - - while (resultSet.one() != null) { - count++; - } - - log.warn("ignoring extra {} row{}", count, count == 1 ? "" : "s"); - } - } - - @Deprecated - protected void warnIfMoreResults(Iterator iterator) { - - if (log.isWarnEnabled() && iterator.hasNext()) { - int count = 0; - - while (iterator.hasNext()) { - count++; - iterator.next(); - } - - log.warn("ignoring extra {} row{}", count, count == 1 ? "" : "s"); - } - } - - /** - * @deprecated as of 1.5, {@link org.springframework.data.cassandra.mapping.CassandraMappingContext} handles type - * conversion. - */ - @Deprecated - public void setConversionService(ConversionService conversionService) { - throw new UnsupportedOperationException("setConversionService(ConversionService) is not supported anymore. " - + "Please use CassandraMappingContext instead"); - } - - /** - * @deprecated as of 1.5, {@link org.springframework.data.cassandra.mapping.CassandraMappingContext} handles type - * conversion. - */ - @Deprecated - public ConversionService getConversionService() { - return template.getConverter().getConversionService(); - } - /** * Creates a string query using the given {@link ParameterAccessor} * diff --git a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java b/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java deleted file mode 100644 index f44f4dda2..000000000 --- a/spring-data-cassandra/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2013-2017 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 - * - * http://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.util; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.cassandra.core.cql.CqlStringUtils; -import org.springframework.data.cassandra.mapping.CassandraPersistentEntity; -import org.springframework.data.cassandra.mapping.CassandraPersistentProperty; -import org.springframework.data.mapping.PropertyHandler; - -import com.datastax.driver.core.ColumnMetadata; -import com.datastax.driver.core.DataType; -import com.datastax.driver.core.TableMetadata; - -/** - * Utilities to convert Cassandra Annotated objects to Queries and CQL. - * - * @author Alex Shvid - * @author David Webb - * @author Matthew T. Adams - * @deprecated need to find a better place for this - */ -@Deprecated -public abstract class CqlUtils { - - /** - * Alter the table to reflect the entity annotations - * - * @param tableName - * @param entity - * @param table - * @return - */ - public static List alterTable(final String tableName, final CassandraPersistentEntity entity, - final TableMetadata table) { - final List result = new ArrayList<>(); - - entity.doWithProperties((PropertyHandler) prop -> { - - String columnName = prop.getColumnName().toCql(); - DataType columnDataType = prop.getDataType(); - ColumnMetadata columnMetadata = table.getColumn(columnName.toLowerCase()); - - if (columnMetadata != null && columnDataType.equals(columnMetadata.getType())) { - return; - } - - final StringBuilder str = new StringBuilder(); - str.append("ALTER TABLE "); - str.append(tableName); - if (columnMetadata == null) { - str.append(" ADD "); - } else { - str.append(" ALTER "); - } - - str.append(columnName); - str.append(' '); - - if (columnMetadata != null) { - str.append("TYPE "); - } - - str.append(CqlStringUtils.toCql(columnDataType)); - - str.append(';'); - result.add(str.toString()); - - }); - - return result; - } -}