DATAKV-251 - Removed off deprecations in Spring Data Commons.
Some additional polishing. Related ticket: DATACMNS-1496.
This commit is contained in:
@@ -30,7 +30,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
class GeneratingIdAccessor implements IdentifierAccessor {
|
||||
|
||||
private final PersistentPropertyAccessor accessor;
|
||||
private final PersistentPropertyAccessor<?> accessor;
|
||||
private final PersistentProperty<?> identifierProperty;
|
||||
private final IdentifierGenerator generator;
|
||||
|
||||
@@ -42,7 +42,7 @@ class GeneratingIdAccessor implements IdentifierAccessor {
|
||||
* @param identifierProperty must not be {@literal null}.
|
||||
* @param generator must not be {@literal null}.
|
||||
*/
|
||||
GeneratingIdAccessor(PersistentPropertyAccessor accessor, PersistentProperty<?> identifierProperty,
|
||||
GeneratingIdAccessor(PersistentPropertyAccessor<?> accessor, PersistentProperty<?> identifierProperty,
|
||||
IdentifierGenerator generator) {
|
||||
|
||||
Assert.notNull(accessor, "PersistentPropertyAccessor must not be null!");
|
||||
|
||||
@@ -174,7 +174,6 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.keyvalue.core.KeyValueOperations#update(java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public <T> T update(T objectToUpdate) {
|
||||
|
||||
@@ -290,7 +289,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.keyvalue.core.KeyValueOperations#delete(java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T delete(T objectToDelete) {
|
||||
|
||||
@@ -447,12 +446,10 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
|
||||
this.adapter.clear();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private KeyValuePersistentEntity<?, ?> getKeyValuePersistentEntity(Object objectToInsert) {
|
||||
return this.mappingContext.getRequiredPersistentEntity(ClassUtils.getUserClass(objectToInsert));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String resolveKeySpace(Class<?> type) {
|
||||
return this.mappingContext.getRequiredPersistentEntity(type).getKeySpace();
|
||||
}
|
||||
|
||||
@@ -126,7 +126,6 @@ public class SpelPropertyComparator<T> implements Comparator<T> {
|
||||
* (non-Javadoc)
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public int compare(T arg1, T arg2) {
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Compara
|
||||
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Collection<?> execute(@Nullable SpelCriteria criteria, @Nullable Comparator<?> sort, long offset, int rows, String keyspace) {
|
||||
public Collection<?> execute(@Nullable SpelCriteria criteria, @Nullable Comparator<?> sort, long offset, int rows,
|
||||
String keyspace) {
|
||||
return sortAndFilterMatchingRange(getRequiredAdapter().getAllOf(keyspace), criteria, sort, offset, rows);
|
||||
}
|
||||
|
||||
@@ -66,9 +67,9 @@ class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Compara
|
||||
.size();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<?> sortAndFilterMatchingRange(Iterable<?> source, @Nullable SpelCriteria criteria, @Nullable Comparator sort,
|
||||
long offset, int rows) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private List<?> sortAndFilterMatchingRange(Iterable<?> source, @Nullable SpelCriteria criteria,
|
||||
@Nullable Comparator sort, long offset, int rows) {
|
||||
|
||||
List<?> tmp = IterableConverter.toList(source);
|
||||
if (sort != null) {
|
||||
@@ -96,7 +97,6 @@ class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Compara
|
||||
return stream.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private static boolean evaluateExpression(SpelCriteria criteria, Object candidate) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -51,7 +51,6 @@ public class SpelSortAccessor implements SortAccessor<Comparator<?>> {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.keyvalue.core.SortAccessor#resolve(org.springframework.data.keyvalue.core.query.KeyValueQuery)
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public Comparator<?> resolve(KeyValueQuery<?> query) {
|
||||
|
||||
|
||||
@@ -57,6 +57,6 @@ public class KeyValueMappingContext<E extends KeyValuePersistentEntity<?, P>, P
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected P createPersistentProperty(Property property, E owner, SimpleTypeHolder simpleTypeHolder) {
|
||||
return (P) new KeyValuePersistentProperty(property, owner, simpleTypeHolder);
|
||||
return (P) new KeyValuePersistentProperty<>(property, owner, simpleTypeHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +154,14 @@ public abstract class KeyValueRepositoryConfigurationExtension extends Repositor
|
||||
|
||||
super.registerBeansForRoot(registry, configurationSource);
|
||||
|
||||
RootBeanDefinition mappingContextDefinition = new RootBeanDefinition(KeyValueMappingContext.class);
|
||||
mappingContextDefinition.setSource(configurationSource.getSource());
|
||||
registerIfNotAlreadyRegistered(() -> {
|
||||
|
||||
registerIfNotAlreadyRegistered(mappingContextDefinition, registry, getMappingContextBeanRef(), configurationSource);
|
||||
RootBeanDefinition definitionefinition = new RootBeanDefinition(KeyValueMappingContext.class);
|
||||
definitionefinition.setSource(configurationSource.getSource());
|
||||
|
||||
return definitionefinition;
|
||||
|
||||
}, registry, getMappingContextBeanRef(), configurationSource);
|
||||
|
||||
Optional<String> keyValueTemplateName = configurationSource.getAttribute(KEY_VALUE_TEMPLATE_BEAN_REF_ATTRIBUTE);
|
||||
|
||||
@@ -168,7 +172,7 @@ public abstract class KeyValueRepositoryConfigurationExtension extends Repositor
|
||||
AbstractBeanDefinition beanDefinition = getDefaultKeyValueTemplateBeanDefinition(configurationSource);
|
||||
|
||||
if (beanDefinition != null) {
|
||||
registerIfNotAlreadyRegistered(beanDefinition, registry, keyValueTemplateName.get(),
|
||||
registerIfNotAlreadyRegistered(() -> beanDefinition, registry, keyValueTemplateName.get(),
|
||||
configurationSource.getSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.data.repository.query.parser.AbstractQueryCreator;
|
||||
import org.springframework.data.spel.EvaluationContextProvider;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -174,22 +173,6 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
|
||||
private Class<? extends AbstractQueryCreator<?, ?>> queryCreator;
|
||||
private Class<? extends RepositoryQuery> repositoryQueryType;
|
||||
|
||||
/**
|
||||
* Creates a new {@link KeyValueQueryLookupStrategy} for the given {@link Key}, {@link EvaluationContextProvider},
|
||||
* {@link KeyValueOperations} and query creator type.
|
||||
* <p>
|
||||
* TODO: Key is not considered. Should it?
|
||||
*
|
||||
* @param key
|
||||
* @param evaluationContextProvider must not be {@literal null}.
|
||||
* @param keyValueOperations must not be {@literal null}.
|
||||
* @param queryCreator must not be {@literal null}.
|
||||
*/
|
||||
public KeyValueQueryLookupStrategy(Key key, QueryMethodEvaluationContextProvider evaluationContextProvider,
|
||||
KeyValueOperations keyValueOperations, Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {
|
||||
this(key, evaluationContextProvider, keyValueOperations, queryCreator, KeyValuePartTreeQuery.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param evaluationContextProvider
|
||||
|
||||
Reference in New Issue
Block a user