Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 936adf8

Browse files
committed
add docs and fix snippet name
1 parent 7ee7361 commit 936adf8

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

  • google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions
  • samples/preview-snippets/src/main/java/com/example/firestore

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3130,12 +3130,26 @@ public static Expression type(String fieldName) {
31303130
return type(field(fieldName));
31313131
}
31323132

3133+
/**
3134+
* Creates an expression that checks if the result of this expression is of the given type.
3135+
*
3136+
* @param expr The expression to check the type of.
3137+
* @param type The type to check for.
3138+
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of the given type, false otherwise.
3139+
*/
31333140
@BetaApi
31343141
public static BooleanExpression isType(Expression expr, Type type) {
31353142
return new BooleanFunctionExpression(
31363143
"is_type", ImmutableList.of(expr, constant(type.name().toLowerCase())));
31373144
}
31383145

3146+
/**
3147+
* Creates an expression that checks if the result of this expression is of the given type.
3148+
*
3149+
* @param fieldName The name of the field to check the type of.
3150+
* @param type The type to check for.
3151+
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of the given type, false otherwise.
3152+
*/
31393153
@BetaApi
31403154
public static BooleanExpression isType(String fieldName, Type type) {
31413155
return new BooleanFunctionExpression(
@@ -4809,6 +4823,12 @@ public final Expression type() {
48094823
return type(this);
48104824
}
48114825

4826+
/**
4827+
* Creates an expression that checks if the result of this expression is of the given type.
4828+
*
4829+
* @param type The type to check for.
4830+
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of the given type, false otherwise.
4831+
*/
48124832
@BetaApi
48134833
public final Expression isType(Type type) {
48144834
return isType(this, type);

samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,15 +1553,15 @@ void vectorLengthFunction() throws ExecutionException, InterruptedException {
15531553
}
15541554

15551555
void isTypeFunction() throws ExecutionException, InterruptedException {
1556-
// [START vector_length]
1556+
// [START is_type]
15571557
Pipeline.Snapshot result =
15581558
firestore
15591559
.pipeline()
15601560
.collection("books")
15611561
.select(field("rating").isType(Type.INT64).as("isRatingInt64"))
15621562
.execute()
15631563
.get();
1564-
// [END vector_length]
1564+
// [END is_type]
15651565
System.out.println(result.getResults());
15661566
}
15671567

0 commit comments

Comments
 (0)