Skip to content

Commit dda3c42

Browse files
committed
add new overloads
1 parent 11a2ef2 commit dda3c42

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed

google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,10 @@ public void onStart(StreamController controller) {
718718

719719
@Override
720720
public void onResponse(ExecutePipelineResponse response) {
721+
if (executionTime == null) {
722+
executionTime = Timestamp.fromProto(response.getExecutionTime());
723+
}
724+
721725
if (!firstResponse) {
722726
firstResponse = true;
723727
Tracing.getTracer()
@@ -739,10 +743,6 @@ public void onResponse(ExecutePipelineResponse response) {
739743
resultObserver.onNext(PipelineResult.fromDocument(rpcContext, executionTime, doc));
740744
}
741745
}
742-
743-
if (executionTime == null) {
744-
executionTime = Timestamp.fromProto(response.getExecutionTime());
745-
}
746746
}
747747

748748
@Override

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expr.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,24 @@ default Like like(String pattern) {
11091109
return new Like(this, Constant.of(pattern));
11101110
}
11111111

1112+
/**
1113+
* Creates an expression that performs a case-sensitive string comparison.
1114+
*
1115+
* <p>Example:
1116+
*
1117+
* <pre>{@code
1118+
* // Check if the 'title' field matches the pattern specified in field 'pattern'.
1119+
* Field.of("title").like(Field.of("pattern"));
1120+
* }</pre>
1121+
*
1122+
* @param pattern The expression evaluates to a pattern.
1123+
* @return A new {@code Expr} representing the 'like' comparison.
1124+
*/
1125+
@BetaApi
1126+
default Like like(Expr pattern) {
1127+
return new Like(this, pattern);
1128+
}
1129+
11121130
/**
11131131
* Creates an expression that checks if a string contains a specified regular expression as a
11141132
* substring.

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Function.java

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,25 @@ public static ByteLength byteLength(String field) {
22502250
return new ByteLength(Field.of(field));
22512251
}
22522252

2253+
/**
2254+
* Creates an expression that performs a case-sensitive wildcard string comparison.
2255+
*
2256+
* <p>Example:
2257+
*
2258+
* <pre>{@code
2259+
* // Check if the 'title' field contains the pattern specified in field 'pattern'.
2260+
* Function.like(Field.of("title"), Field.of("pattern"));
2261+
* }</pre>
2262+
*
2263+
* @param expr The expression representing the string to perform the comparison on.
2264+
* @param pattern The expression evaluates to the pattern to compare to.
2265+
* @return A new {@code Expr} representing the 'like' comparison.
2266+
*/
2267+
@BetaApi
2268+
public static Like like(Expr expr, Expr pattern) {
2269+
return new Like(expr, pattern);
2270+
}
2271+
22532272
/**
22542273
* Creates an expression that performs a case-sensitive wildcard string comparison.
22552274
*
@@ -2289,6 +2308,26 @@ public static Like like(String field, String pattern) {
22892308
return new Like(Field.of(field), Constant.of(pattern));
22902309
}
22912310

2311+
/**
2312+
* Creates an expression that checks if a string expression contains a specified regular
2313+
* expression as a substring.
2314+
*
2315+
* <p>Example:
2316+
*
2317+
* <pre>{@code
2318+
* // Check if the 'description' field contains "example" (case-insensitive)
2319+
* Function.regexContains(Field.of("description"), Constant.of("(?i)example"));
2320+
* }</pre>
2321+
*
2322+
* @param expr The expression representing the string to perform the comparison on.
2323+
* @param pattern The expression evaluates to a regular expression string.
2324+
* @return A new {@code Expr} representing the 'contains' comparison.
2325+
*/
2326+
@BetaApi
2327+
public static RegexContains regexContains(Expr expr, Expr pattern) {
2328+
return new RegexContains(expr, pattern);
2329+
}
2330+
22922331
/**
22932332
* Creates an expression that checks if a string expression contains a specified regular
22942333
* expression as a substring.
@@ -2329,6 +2368,26 @@ public static RegexContains regexContains(String field, String pattern) {
23292368
return new RegexContains(Field.of(field), Constant.of(pattern));
23302369
}
23312370

2371+
/**
2372+
* Creates an expression that checks if a string expression matches a specified regular
2373+
* expression.
2374+
*
2375+
* <p>Example:
2376+
*
2377+
* <pre>{@code
2378+
* // Check if the 'email' field matches a valid email pattern
2379+
* Function.regexMatch(Field.of("email"), Constant.of("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"));
2380+
* }</pre>
2381+
*
2382+
* @param expr The expression representing the string to match against.
2383+
* @param pattern The expression evaluates to a regular expression string.
2384+
* @return A new {@code Expr} representing the regular expression match.
2385+
*/
2386+
@BetaApi
2387+
public static RegexMatch regexMatch(Expr expr, Expr pattern) {
2388+
return new RegexMatch(expr, pattern);
2389+
}
2390+
23322391
/**
23332392
* Creates an expression that checks if a string expression matches a specified regular
23342393
* expression.
@@ -2368,6 +2427,25 @@ public static RegexMatch regexMatch(String field, String pattern) {
23682427
return new RegexMatch(Field.of(field), Constant.of(pattern));
23692428
}
23702429

2430+
/**
2431+
* Creates an expression that checks if a string expression contains a specified substring.
2432+
*
2433+
* <p>Example:
2434+
*
2435+
* <pre>{@code
2436+
* // Check if the 'description' field contains "example".
2437+
* Function.regexContains(Field.of("description"), Constant.of("example"));
2438+
* }</pre>
2439+
*
2440+
* @param expr The expression representing the string to perform the comparison on.
2441+
* @param substring The expression evaluates to a substring to use for the search.
2442+
* @return A new {@code Expr} representing the 'contains' comparison.
2443+
*/
2444+
@BetaApi
2445+
public static StrContains strContains(Expr expr, Expr substring) {
2446+
return new StrContains(expr, Constant.of(substring));
2447+
}
2448+
23712449
/**
23722450
* Creates an expression that checks if a string expression contains a specified substring.
23732451
*

0 commit comments

Comments
 (0)