This commit is contained in:
Timo Westkämper 2011-02-28 14:54:03 +00:00
parent 4c9f689467
commit bd2a65e947
3 changed files with 39 additions and 5 deletions

View File

@ -6,8 +6,4 @@ not expansion for
contains
containsKey
containsValue
like
matches
startsWith
endsWith
contains

View File

@ -417,9 +417,38 @@ trait StringExpression extends ComparableExpression[String] {
override def as(right: Path[String]) = string(ALIAS.asInstanceOf[Operator[String]], this, right);
override def as(alias: String): StringExpression = as(new PathImpl[String](getType, alias));
def not() = new StringNegations(this)
}
// NOTE : experimental
class StringNegations (val str: StringExpression) {
def like(right: String): BooleanExpression = str.like(right).not;
def like(right: Expression[String]) = str.like(right).not;
def matches(right: String) = str.matches(right).not;
def matches(right: Expression[String]) = str.matches(right).not;
def contains(right: String) = str.contains(right).not;
def contains(right: Expression[String]) = str.contains(right).not;
def startsWith(right: String) = str.startsWith(right).not;
def startsWith(right: Expression[String]) = str.startsWith(right).not;
def endsWith(right: String) = str.endsWith(right).not;
def endsWith(right: Expression[String]) = str.endsWith(right).not;
def empty = str.isNotEmpty;
}
trait TemporalExpression[T <: Comparable[_]] extends ComparableExpression[T] {
def after(right: T) = gt(right);

View File

@ -295,6 +295,15 @@ class ExpressionTest {
assertEquals("endsWith(person.firstName,amin)", person.firstName endsWith "amin");
}
@Test
def String_Negations {
assertEquals("!person.firstName like XXX", person.firstName not() like "XXX"); // FIXME
assertEquals("!matches(person.firstName,XXX)", person.firstName not() matches "XXX"); // FIXME
assertEquals("!startsWith(person.firstName,XXX)", person.firstName not() startsWith"XXX"); // FIXME
assertEquals("!endsWith(person.firstName,XXX)", person.firstName not() endsWith "XXX"); // FIXME
assertEquals("!empty(person.firstName)", person.firstName not() empty); // FIXME
}
// @Test
// def Prefix(){
// assertEquals("count(person)", count(person));