summaryrefslogtreecommitdiffstats
path: root/predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java
diff options
context:
space:
mode:
Diffstat (limited to 'predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java')
-rw-r--r--predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java b/predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java
new file mode 100644
index 00000000000..7362eb5ba6d
--- /dev/null
+++ b/predicate-search-core/src/main/java/com/yahoo/document/predicate/Predicates.java
@@ -0,0 +1,69 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.document.predicate;
+
+/**
+ * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a>
+ */
+public class Predicates {
+
+ public static Conjunction and(Predicate... operands) {
+ return new Conjunction(operands);
+ }
+
+ public static Disjunction or(Predicate... operands) {
+ return new Disjunction(operands);
+ }
+
+ public static Negation not(Predicate operand) {
+ return new Negation(operand);
+ }
+
+ public static BooleanPredicate value(boolean value) {
+ return new BooleanPredicate(value);
+ }
+
+ public static FeatureBuilder feature(String key) {
+ return new FeatureBuilder(key);
+ }
+
+ public static class FeatureBuilder {
+
+ private final String key;
+
+ public FeatureBuilder(String key) {
+ this.key = key;
+ }
+
+ public FeatureRange lessThan(long toExclusive) {
+ return new FeatureRange(key, null, toExclusive - 1);
+ }
+
+ public FeatureRange lessThanOrEqualTo(long toInclusive) {
+ return new FeatureRange(key, null, toInclusive);
+ }
+
+ public FeatureRange greaterThan(long fromExclusive) {
+ return new FeatureRange(key, fromExclusive + 1, null);
+ }
+
+ public FeatureRange greaterThanOrEqualTo(long fromInclusive) {
+ return new FeatureRange(key, fromInclusive, null);
+ }
+
+ public FeatureRange inRange(long fromInclusive, long toInclusive) {
+ return new FeatureRange(key, fromInclusive, toInclusive);
+ }
+
+ public Negation notInRange(long fromInclusive, long toInclusive) {
+ return new Negation(new FeatureRange(key, fromInclusive, toInclusive));
+ }
+
+ public FeatureSet inSet(String... values) {
+ return new FeatureSet(key, values);
+ }
+
+ public Negation notInSet(String... values) {
+ return new Negation(new FeatureSet(key, values));
+ }
+ }
+}