|
30 | 30 | @Internal |
31 | 31 | public final class NitriteQueryOperators { |
32 | 32 |
|
| 33 | + /** Logical AND operator. */ |
33 | 34 | public static final String AND = "$and"; |
| 35 | + /** Logical OR operator. */ |
34 | 36 | public static final String OR = "$or"; |
| 37 | + /** Logical NOT operator. */ |
35 | 38 | public static final String NOT = "$not"; |
| 39 | + /** Expression operator. */ |
36 | 40 | public static final String EXPR = "$expr"; |
| 41 | + /** Exists operator. */ |
37 | 42 | public static final String EXISTS = "$exists"; |
| 43 | + /** Empty operator. */ |
38 | 44 | public static final String EMPTY = "$empty"; |
| 45 | + /** Text search operator. */ |
39 | 46 | public static final String TEXT = "$text"; |
| 47 | + /** All operator for array matching. */ |
40 | 48 | public static final String ALL = "$all"; |
41 | 49 |
|
| 50 | + /** Equals operator. */ |
42 | 51 | public static final String EQ = "$eq"; |
| 52 | + /** Not-equals operator. */ |
43 | 53 | public static final String NE = "$ne"; |
| 54 | + /** Greater-than operator. */ |
44 | 55 | public static final String GT = "$gt"; |
| 56 | + /** Greater-than-or-equal operator. */ |
45 | 57 | public static final String GTE = "$gte"; |
| 58 | + /** Less-than operator. */ |
46 | 59 | public static final String LT = "$lt"; |
| 60 | + /** Less-than-or-equal operator. */ |
47 | 61 | public static final String LTE = "$lte"; |
| 62 | + /** In operator. */ |
48 | 63 | public static final String IN = "$in"; |
| 64 | + /** Not-in operator. */ |
49 | 65 | public static final String NIN = "$nin"; |
| 66 | + /** Between operator. */ |
50 | 67 | public static final String BETWEEN = "$between"; |
| 68 | + /** Regex operator. */ |
51 | 69 | public static final String REGEX = "$regex"; |
| 70 | + /** Like operator. */ |
52 | 71 | public static final String LIKE = "$like"; |
| 72 | + /** Null operator. */ |
53 | 73 | public static final String NULL = "$null"; |
| 74 | + /** Not-null operator. */ |
54 | 75 | public static final String NOT_NULL = "$notNull"; |
55 | 76 |
|
| 77 | + /** String length operator. */ |
56 | 78 | public static final String STR_LEN_CP = "$strLenCP"; |
| 79 | + /** To-lower operator. */ |
57 | 80 | public static final String TO_LOWER = "$toLower"; |
| 81 | + /** To-upper operator. */ |
58 | 82 | public static final String TO_UPPER = "$toUpper"; |
| 83 | + /** Multiply operator. */ |
59 | 84 | public static final String MULTIPLY = "$multiply"; |
| 85 | + /** Concatenate operator. */ |
60 | 86 | public static final String CONCAT = "$concat"; |
| 87 | + /** Substring operator. */ |
61 | 88 | public static final String SUBSTR_CP = "$substrCP"; |
| 89 | + /** Right substring operator. */ |
62 | 90 | public static final String RIGHT = "$right"; |
| 91 | + /** Divide operator. */ |
63 | 92 | public static final String DIVIDE = "$divide"; |
| 93 | + /** To-double operator. */ |
64 | 94 | public static final String TO_DOUBLE = "$toDouble"; |
65 | 95 |
|
| 96 | + /** Near geospatial operator. */ |
66 | 97 | public static final String NEAR = "$near"; |
| 98 | + /** Within geospatial operator. */ |
67 | 99 | public static final String WITHIN = "$within"; |
| 100 | + /** Intersects geospatial operator. */ |
68 | 101 | public static final String INTERSECTS = "$intersects"; |
69 | 102 |
|
70 | 103 | private NitriteQueryOperators() { |
71 | 104 | } |
72 | 105 |
|
| 106 | + /** |
| 107 | + * Creates a single-operator query map entry. |
| 108 | + * |
| 109 | + * @param operator the operator name |
| 110 | + * @param value the value to match |
| 111 | + * @return a singleton map containing the operator and value |
| 112 | + */ |
73 | 113 | public static Map<String, @Nullable Object> operator(String operator, @Nullable Object value) { |
74 | 114 | return Collections.singletonMap(operator, value); |
75 | 115 | } |
76 | 116 |
|
| 117 | + /** |
| 118 | + * Creates an expression query wrapping the given operator and operands. |
| 119 | + * |
| 120 | + * @param operator the operator name |
| 121 | + * @param operands the list of operands |
| 122 | + * @return a map containing the {@code $expr} expression |
| 123 | + */ |
77 | 124 | public static Map<String, Object> expression(String operator, List<?> operands) { |
78 | 125 | return Map.of(EXPR, operator(operator, operands)); |
79 | 126 | } |
|
0 commit comments