1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright 2017 Yahoo Holdings. 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));
}
}
}
|