DATAKV-170 - Fix KeyValue.getCriteria() method name.

Introduce KeyValue.getCriteria() method and deprecate KeyValue.getCritieria() for later removal. Use fixed method in affected classes.
This commit is contained in:
Mark Paluch
2017-04-20 13:03:53 +02:00
parent cc51ec8c47
commit 3f21f10d78
9 changed files with 39 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-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.
@@ -19,16 +19,16 @@ import org.springframework.data.keyvalue.core.query.KeyValueQuery;
/**
* Resolves the criteria object from given {@link KeyValueQuery}.
*
*
* @author Christoph Strobl
* @param <T>
*/
public interface CriteriaAccessor<T> {
/**
* Checks and reads {@link KeyValueQuery#getCritieria()} of given {@link KeyValueQuery}. Might also apply additional
* Checks and reads {@link KeyValueQuery#getCriteria()} of given {@link KeyValueQuery}. Might also apply additional
* transformation to match the desired type.
*
*
* @param query can be {@literal null}.
* @return the criteria extracted from the query.
* @throws IllegalArgumentException in case the criteria is not valid for usage with specific {@link CriteriaAccessor}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-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.
@@ -22,7 +22,7 @@ import org.springframework.util.Assert;
/**
* {@link CriteriaAccessor} implementation capable of {@link SpelExpression}s.
*
*
* @author Christoph Strobl
* @author Oliver Gierke
*/
@@ -32,7 +32,7 @@ class SpelCriteriaAccessor implements CriteriaAccessor<SpelCriteria> {
/**
* Creates a new {@link SpelCriteriaAccessor} using the given {@link SpelExpressionParser}.
*
*
* @param parser must not be {@literal null}.
*/
public SpelCriteriaAccessor(SpelExpressionParser parser) {
@@ -49,22 +49,22 @@ class SpelCriteriaAccessor implements CriteriaAccessor<SpelCriteria> {
@Override
public SpelCriteria resolve(KeyValueQuery<?> query) {
if (query.getCritieria() == null) {
if (query.getCriteria() == null) {
return null;
}
if (query.getCritieria() instanceof SpelExpression) {
return new SpelCriteria((SpelExpression) query.getCritieria());
if (query.getCriteria() instanceof SpelExpression) {
return new SpelCriteria((SpelExpression) query.getCriteria());
}
if (query.getCritieria() instanceof String) {
return new SpelCriteria(parser.parseRaw((String) query.getCritieria()));
if (query.getCriteria() instanceof String) {
return new SpelCriteria(parser.parseRaw((String) query.getCriteria()));
}
if (query.getCritieria() instanceof SpelCriteria) {
return (SpelCriteria) query.getCritieria();
if (query.getCriteria() instanceof SpelCriteria) {
return (SpelCriteria) query.getCriteria();
}
throw new IllegalArgumentException("Cannot create SpelCriteria for " + query.getCritieria());
throw new IllegalArgumentException("Cannot create SpelCriteria for " + query.getCriteria());
}
}

View File

@@ -56,11 +56,23 @@ public class KeyValueQuery<T> {
* Get the criteria object.
*
* @return
* @deprecated will be removed in favor of {@link #getCriteria()}.
*/
@Deprecated
public T getCritieria() {
return criteria;
}
/**
* Get the criteria object.
*
* @return
* @since 2.0
*/
public T getCriteria() {
return criteria;
}
/**
* Get {@link Sort}.
*

View File

@@ -135,7 +135,7 @@ public class KeyValuePartTreeQuery implements RepositoryQuery {
ParametersParameterAccessor accessor = new ParametersParameterAccessor(getQueryMethod().getParameters(),
parameters);
Object criteria = instance.getCritieria();
Object criteria = instance.getCriteria();
if (criteria instanceof SpelCriteria || criteria instanceof SpelExpression) {