Skip to content

Commit

Permalink
Merge pull request #3 from mpikielny/master
Browse files Browse the repository at this point in the history
Added valueIn to Internal visitor
  • Loading branch information
denis-itskovich authored May 28, 2019
2 parents a467cb2 + ca422c5 commit 77aea9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.Test;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

import static com.slimgears.rxrepo.filters.ComparableFilter.fromGreaterOrEqual;
Expand Down Expand Up @@ -108,4 +109,16 @@ public void testAnnotationRetrieval() {
Assert.assertTrue(TestEntity.metaClass.number.hasAnnotation(Indexable.class));
Assert.assertFalse(TestEntity.metaClass.refEntity.hasAnnotation(Indexable.class));
}

@Test
public void testValueInExpression() {
List<String> strings = Collections.singletonList("Entity 1");
Function<TestEntity, Boolean> exp = Expressions
.compile(TestEntity.$.text.in(strings));

Assert.assertTrue(exp.apply(testEntity1));
Assert.assertFalse(exp.apply(testEntity2));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private static class InternalVisitor extends ExpressionVisitor<Void, Function> {
.put(Expression.Type.Max, notSupported())
.put(Expression.Type.Sum, notSupported())
.put(Expression.Type.SearchText, Expressions.fromBinary((Object obj, String str) -> obj.toString().contains(str)))
.put(Expression.Type.ValueIn, Expressions.fromBinary((Object obj, Collection<Object> collection) -> collection.contains(obj)))
.build();

private final static ImmutableMap<Expression.OperationType, Function<Function[], Function>> operationTypeReducersMap = ImmutableMap.<Expression.OperationType, Function<Function[], Function>>builder()
Expand Down

0 comments on commit 77aea9d

Please sign in to comment.