diff --git a/src/main/java/org/springframework/data/keyvalue/core/CriteriaAccessor.java b/src/main/java/org/springframework/data/keyvalue/core/CriteriaAccessor.java index 389d65b..dd61ca8 100644 --- a/src/main/java/org/springframework/data/keyvalue/core/CriteriaAccessor.java +++ b/src/main/java/org/springframework/data/keyvalue/core/CriteriaAccessor.java @@ -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 */ public interface CriteriaAccessor { /** - * 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} diff --git a/src/main/java/org/springframework/data/keyvalue/core/SpelCriteriaAccessor.java b/src/main/java/org/springframework/data/keyvalue/core/SpelCriteriaAccessor.java index 710a6b2..66c9da6 100644 --- a/src/main/java/org/springframework/data/keyvalue/core/SpelCriteriaAccessor.java +++ b/src/main/java/org/springframework/data/keyvalue/core/SpelCriteriaAccessor.java @@ -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 { /** * 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 { @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()); } } diff --git a/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java b/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java index 1a14be6..e08725c 100644 --- a/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java +++ b/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java @@ -56,11 +56,23 @@ public class KeyValueQuery { * 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}. * diff --git a/src/main/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQuery.java b/src/main/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQuery.java index 1b09444..82d09f2 100644 --- a/src/main/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQuery.java +++ b/src/main/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQuery.java @@ -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) { diff --git a/src/test/java/org/springframework/data/keyvalue/core/KeyValueTemplateUnitTests.java b/src/test/java/org/springframework/data/keyvalue/core/KeyValueTemplateUnitTests.java index ba028ec..1bc341d 100644 --- a/src/test/java/org/springframework/data/keyvalue/core/KeyValueTemplateUnitTests.java +++ b/src/test/java/org/springframework/data/keyvalue/core/KeyValueTemplateUnitTests.java @@ -216,7 +216,7 @@ public class KeyValueTemplateUnitTests { verify(adapterMock, times(1)).find(captor.capture(), eq(Foo.class.getName()), eq(Foo.class)); assertThat(captor.getValue().getOffset(), is(1L)); assertThat(captor.getValue().getRows(), is(5)); - assertThat(captor.getValue().getCritieria(), nullValue()); + assertThat(captor.getValue().getCriteria(), nullValue()); } @Test // DATACMNS-525 diff --git a/src/test/java/org/springframework/data/keyvalue/core/SpelQueryEngineUnitTests.java b/src/test/java/org/springframework/data/keyvalue/core/SpelQueryEngineUnitTests.java index 316694a..d071c17 100644 --- a/src/test/java/org/springframework/data/keyvalue/core/SpelQueryEngineUnitTests.java +++ b/src/test/java/org/springframework/data/keyvalue/core/SpelQueryEngineUnitTests.java @@ -99,7 +99,7 @@ public class SpelQueryEngineUnitTests { SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor( new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args)); - return new SpelCriteria(creator.createQuery().getCritieria(), new StandardEvaluationContext(args)); + return new SpelCriteria(creator.createQuery().getCriteria(), new StandardEvaluationContext(args)); } static interface PersonRepository { diff --git a/src/test/java/org/springframework/data/keyvalue/repository/query/CachingKeyValuePartTreeQueryUnitTests.java b/src/test/java/org/springframework/data/keyvalue/repository/query/CachingKeyValuePartTreeQueryUnitTests.java index 09e7bed..93743f4 100644 --- a/src/test/java/org/springframework/data/keyvalue/repository/query/CachingKeyValuePartTreeQueryUnitTests.java +++ b/src/test/java/org/springframework/data/keyvalue/repository/query/CachingKeyValuePartTreeQueryUnitTests.java @@ -68,8 +68,8 @@ public class CachingKeyValuePartTreeQueryUnitTests { Object[] args = new Object[] { "foo" }; - SpelCriteria first = (SpelCriteria) query.prepareQuery(args).getCritieria(); - SpelCriteria second = (SpelCriteria) query.prepareQuery(args).getCritieria(); + SpelCriteria first = (SpelCriteria) query.prepareQuery(args).getCriteria(); + SpelCriteria second = (SpelCriteria) query.prepareQuery(args).getCriteria(); assertThat(first.getExpression(), sameInstance(second.getExpression())); assertThat(first.getContext(), not(sameInstance(second.getContext()))); diff --git a/src/test/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQueryUnitTests.java b/src/test/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQueryUnitTests.java index 928dfc1..2913a37 100644 --- a/src/test/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQueryUnitTests.java +++ b/src/test/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQueryUnitTests.java @@ -64,8 +64,8 @@ public class KeyValuePartTreeQueryUnitTests { Object[] args = new Object[] { "foo" }; - Object first = query.prepareQuery(args).getCritieria(); - Object second = query.prepareQuery(args).getCritieria(); + Object first = query.prepareQuery(args).getCriteria(); + Object second = query.prepareQuery(args).getCriteria(); assertThat(first, not(sameInstance(second))); } @@ -121,9 +121,9 @@ public class KeyValuePartTreeQueryUnitTests { KeyValueQuery query = partTreeQuery.prepareQuery(new Object[] { "firstname" }); - assertThat(query.getCritieria(), is(notNullValue())); - assertThat(query.getCritieria(), IsInstanceOf.instanceOf(SpelCriteria.class)); - assertThat(((SpelCriteria) query.getCritieria()).getExpression().getExpressionString(), + assertThat(query.getCriteria(), is(notNullValue())); + assertThat(query.getCriteria(), IsInstanceOf.instanceOf(SpelCriteria.class)); + assertThat(((SpelCriteria) query.getCriteria()).getExpression().getExpressionString(), is("#it?.firstname?.equals([0])")); assertThat(query.getRows(), is(3)); } diff --git a/src/test/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreatorUnitTests.java b/src/test/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreatorUnitTests.java index e21fa92..8491c66 100644 --- a/src/test/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreatorUnitTests.java +++ b/src/test/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreatorUnitTests.java @@ -307,7 +307,7 @@ public class SpelQueryCreatorUnitTests { } private Evaluation evaluate(String methodName, Object... args) throws Exception { - return new Evaluation((SpelExpression) createQueryForMethodWithArgs(methodName, args).getCritieria()); + return new Evaluation((SpelExpression) createQueryForMethodWithArgs(methodName, args).getCriteria()); } private KeyValueQuery createQueryForMethodWithArgs(String methodName, Object... args) @@ -329,7 +329,7 @@ public class SpelQueryCreatorUnitTests { new QueryMethod(method, metadataMock, new SpelAwareProxyProjectionFactory()).getParameters(), args)); KeyValueQuery q = creator.createQuery(); - q.getCritieria().setEvaluationContext(new StandardEvaluationContext(args)); + q.getCriteria().setEvaluationContext(new StandardEvaluationContext(args)); return q; }