Skip to content

Commit d30fb6d

Browse files
committed
Add missing Javadoc to data-nitrite public API
1 parent 2b91f77 commit d30fb6d

3 files changed

Lines changed: 82 additions & 1 deletion

File tree

data-nitrite/src/main/java/io/micronaut/data/nitrite/model/query/NitriteQueryOperators.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,50 +30,97 @@
3030
@Internal
3131
public final class NitriteQueryOperators {
3232

33+
/** Logical AND operator. */
3334
public static final String AND = "$and";
35+
/** Logical OR operator. */
3436
public static final String OR = "$or";
37+
/** Logical NOT operator. */
3538
public static final String NOT = "$not";
39+
/** Expression operator. */
3640
public static final String EXPR = "$expr";
41+
/** Exists operator. */
3742
public static final String EXISTS = "$exists";
43+
/** Empty operator. */
3844
public static final String EMPTY = "$empty";
45+
/** Text search operator. */
3946
public static final String TEXT = "$text";
47+
/** All operator for array matching. */
4048
public static final String ALL = "$all";
4149

50+
/** Equals operator. */
4251
public static final String EQ = "$eq";
52+
/** Not-equals operator. */
4353
public static final String NE = "$ne";
54+
/** Greater-than operator. */
4455
public static final String GT = "$gt";
56+
/** Greater-than-or-equal operator. */
4557
public static final String GTE = "$gte";
58+
/** Less-than operator. */
4659
public static final String LT = "$lt";
60+
/** Less-than-or-equal operator. */
4761
public static final String LTE = "$lte";
62+
/** In operator. */
4863
public static final String IN = "$in";
64+
/** Not-in operator. */
4965
public static final String NIN = "$nin";
66+
/** Between operator. */
5067
public static final String BETWEEN = "$between";
68+
/** Regex operator. */
5169
public static final String REGEX = "$regex";
70+
/** Like operator. */
5271
public static final String LIKE = "$like";
72+
/** Null operator. */
5373
public static final String NULL = "$null";
74+
/** Not-null operator. */
5475
public static final String NOT_NULL = "$notNull";
5576

77+
/** String length operator. */
5678
public static final String STR_LEN_CP = "$strLenCP";
79+
/** To-lower operator. */
5780
public static final String TO_LOWER = "$toLower";
81+
/** To-upper operator. */
5882
public static final String TO_UPPER = "$toUpper";
83+
/** Multiply operator. */
5984
public static final String MULTIPLY = "$multiply";
85+
/** Concatenate operator. */
6086
public static final String CONCAT = "$concat";
87+
/** Substring operator. */
6188
public static final String SUBSTR_CP = "$substrCP";
89+
/** Right substring operator. */
6290
public static final String RIGHT = "$right";
91+
/** Divide operator. */
6392
public static final String DIVIDE = "$divide";
93+
/** To-double operator. */
6494
public static final String TO_DOUBLE = "$toDouble";
6595

96+
/** Near geospatial operator. */
6697
public static final String NEAR = "$near";
98+
/** Within geospatial operator. */
6799
public static final String WITHIN = "$within";
100+
/** Intersects geospatial operator. */
68101
public static final String INTERSECTS = "$intersects";
69102

70103
private NitriteQueryOperators() {
71104
}
72105

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+
*/
73113
public static Map<String, @Nullable Object> operator(String operator, @Nullable Object value) {
74114
return Collections.singletonMap(operator, value);
75115
}
76116

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+
*/
77124
public static Map<String, Object> expression(String operator, List<?> operands) {
78125
return Map.of(EXPR, operator(operator, operands));
79126
}

data-nitrite/src/main/java/io/micronaut/data/nitrite/runtime/query/PatternConverter.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,23 @@
1919
import io.micronaut.core.annotation.Nullable;
2020
import java.util.regex.Pattern;
2121

22+
/**
23+
* Converts LIKE patterns and wildcards to regular expressions for Nitrite queries.
24+
*
25+
* @since 5.0.0
26+
*/
2227
@Internal
2328
public final class PatternConverter {
2429

2530
private PatternConverter() { }
2631

32+
/**
33+
* Resolves a regex pattern from the given value. Handles {@link Pattern} instances,
34+
* slash-delimited patterns, and wildcard (LIKE) patterns.
35+
*
36+
* @param resolved the raw pattern value
37+
* @return the resolved regex pattern string
38+
*/
2739
public static String resolveRegexPattern(@Nullable Object resolved) {
2840
if (resolved == null) {
2941
return "";
@@ -46,6 +58,13 @@ public static String resolveRegexPattern(@Nullable Object resolved) {
4658
return flags + value;
4759
}
4860

61+
/**
62+
* Returns {@code true} if the value looks like a wildcard pattern
63+
* containing {@code %}, {@code _}, or {@code *} characters.
64+
*
65+
* @param value the value to inspect
66+
* @return {@code true} if the value contains wildcard characters
67+
*/
4968
public static boolean looksLikeWildcardPattern(String value) {
5069
if (value == null || value.isEmpty()) {
5170
return false;
@@ -57,10 +76,23 @@ public static boolean looksLikeWildcardPattern(String value) {
5776
return value.indexOf('%') >= 0 || value.indexOf('_') >= 0 || value.indexOf('*') >= 0;
5877
}
5978

79+
/**
80+
* Converts a LIKE pattern to a regex string using no escape character.
81+
*
82+
* @param pattern the LIKE pattern
83+
* @return the equivalent regex string
84+
*/
6085
public static String convertLikeToRegex(String pattern) {
6186
return convertLikeToRegex(pattern, null);
6287
}
6388

89+
/**
90+
* Converts a LIKE pattern to a regex string with an optional escape character.
91+
*
92+
* @param pattern the LIKE pattern
93+
* @param escapeChar the escape character, or {@code null} for none
94+
* @return the equivalent regex string
95+
*/
6496
public static String convertLikeToRegex(String pattern, @Nullable Character escapeChar) {
6597
StringBuilder regex = new StringBuilder(pattern.length() + 6);
6698
if (pattern.isEmpty() || pattern.charAt(0) != '^') {

data-nitrite/src/main/java/io/micronaut/data/nitrite/runtime/write/NitriteOperationContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public NitriteOperationContext(AnnotationMetadata annotationMetadata, Class<?> r
4545
}
4646

4747
/**
48-
* @return Whether this operation came from an explicit insert method.
48+
* Returns whether this operation came from an explicit insert method.
49+
*
50+
* @return {@code true} if the operation originated from an explicit insert method
4951
*/
5052
public boolean isStrictInsert() {
5153
return strictInsert;

0 commit comments

Comments
 (0)