DATACMNS-433 - Added Is prefix to Like keywords.

Like expressions are now also recognized if they're prefixed with Is. So both "IsLike" and "Like" are recognized as well as "NotLike" and "IsNotLike".
This commit is contained in:
Martin Baumgartner
2014-02-02 20:25:47 +01:00
committed by Oliver Gierke
parent 659d64d63b
commit bedbe926b9
2 changed files with 25 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2013 the original author or authors.
* Copyright 2008-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.
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
* {@link #getProperty()}.
*
* @author Oliver Gierke
* @author Martin Baumgartner
*/
public class Part {
@@ -181,11 +182,11 @@ public class Part {
BETWEEN(2, "IsBetween", "Between"), IS_NOT_NULL(0, "IsNotNull", "NotNull"), IS_NULL(0, "IsNull", "Null"), LESS_THAN(
"IsLessThan", "LessThan"), LESS_THAN_EQUAL("IsLessThanEqual", "LessThanEqual"), GREATER_THAN("IsGreaterThan",
"GreaterThan"), GREATER_THAN_EQUAL("IsGreaterThanEqual", "GreaterThanEqual"), BEFORE("IsBefore", "Before"), AFTER(
"IsAfter", "After"), NOT_LIKE("NotLike"), LIKE("Like"), STARTING_WITH("IsStartingWith", "StartingWith",
"StartsWith"), ENDING_WITH("IsEndingWith", "EndingWith", "EndsWith"), CONTAINING("IsContaining", "Containing",
"Contains"), NOT_IN("IsNotIn", "NotIn"), IN("IsIn", "In"), NEAR("IsNear", "Near"), WITHIN("IsWithin", "Within"), REGEX(
"MatchesRegex", "Matches", "Regex"), EXISTS(0, "Exists"), TRUE(0, "IsTrue", "True"), FALSE(0, "IsFalse",
"False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals");
"IsAfter", "After"), NOT_LIKE("IsNotLike", "NotLike"), LIKE("IsLike", "Like"), STARTING_WITH("IsStartingWith",
"StartingWith", "StartsWith"), ENDING_WITH("IsEndingWith", "EndingWith", "EndsWith"), CONTAINING(
"IsContaining", "Containing", "Contains"), NOT_IN("IsNotIn", "NotIn"), IN("IsIn", "In"), NEAR("IsNear", "Near"), WITHIN(
"IsWithin", "Within"), REGEX("MatchesRegex", "Matches", "Regex"), EXISTS(0, "Exists"), TRUE(0, "IsTrue", "True"), FALSE(
0, "IsFalse", "False"), NEGATING_SIMPLE_PROPERTY("IsNot", "Not"), SIMPLE_PROPERTY("Is", "Equals");
// Need to list them again explicitly as the order is important
// (esp. for IS_NULL, IS_NOT_NULL)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2013 the original author or authors.
* Copyright 2008-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
@@ -41,6 +41,7 @@ import org.springframework.data.repository.query.parser.PartTree.OrPart;
* @author Oliver Gierke
* @author Phillip Webb
* @author Thomas Darimont
* @author Martin Baumgartner
*/
public class PartTreeUnitTests {
@@ -295,6 +296,22 @@ public class PartTreeUnitTests {
public void parsesBeforeKeywordCorrectly() {
assertType(Arrays.asList("birthdayBefore", "birthdayIsBefore"), Type.BEFORE, "birthday");
}
/**
* @see DATACMNS-433
*/
@Test
public void parsesLikeKeywordCorrectly() {
assertType(asList("activeLike", "activeIsLike"), LIKE, "active");
}
/**
* @see DATACMNS-433
*/
@Test
public void parsesNotLikeKeywordCorrectly() {
assertType(asList("activeNotLike", "activeIsNotLike"), NOT_LIKE, "active");
}
/**
* @see DATACMNS-182