This commit is contained in:
Timo Westkämper 2011-03-01 08:57:05 +00:00
parent 9b2cddcf35
commit 3a83024088
3 changed files with 19 additions and 3 deletions

View File

@ -70,7 +70,9 @@ trait SimpleExpression[T] extends Expression[T]{
def notIn(right: CollectionExpression[T,_]) = in(right).not;
def not[M <: SimpleExpression[T]](f: (M) => BooleanExpression): BooleanExpression = f(this.asInstanceOf[M]).not();
def is[M <: SimpleExpression[T]](f: M => BooleanExpression): BooleanExpression = if (f == null) isNull() else f(this.asInstanceOf[M]);
def not[M <: SimpleExpression[T]](f: M => BooleanExpression): BooleanExpression = f(this.asInstanceOf[M]).not();
}

View File

@ -4,7 +4,9 @@ import com.mysema.query.types._
object Matchers {
// def in[T](values: T*) = (expr: SimpleExpression[T]) => expr.in(values);
def in[T](values: T*) = (expr: SimpleExpression[T]) => expr.in(values:_*);
def not(v: Void) = (expr: SimpleExpression[_]) => expr.isNotNull();
// map

View File

@ -14,6 +14,18 @@ class ExpressionTest {
Assert.assertEquals(expected, actual.toString);
}
@Test
def Is_Not_Null {
assertEquals("person.other is not null", person.other isNotNull);
assertEquals("person.other is not null", person.other is not(null) );
}
@Test
def Is_Null {
assertEquals("person.other is null", person.other isNull);
assertEquals("person.other is null", person.other is null );
}
@Test
def Long_Path {
assertEquals("person.other.firstName = Ben", person.other.firstName eq "Ben");
@ -98,7 +110,7 @@ class ExpressionTest {
@Test
def String_Or_With_Operators {
val orClause = (person.firstName like "An%") or (person.firstName like "Be%");
val orClause = (person.firstName like "An%") || (person.firstName like "Be%");
assertEquals("person.firstName like An% || person.firstName like Be%", orClause);
}