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

Commit 1d19963

Browse files
committed
replace enum with string
1 parent 999086f commit 1d19963

3 files changed

Lines changed: 39 additions & 73 deletions

File tree

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3131,31 +3131,38 @@ public static Expression type(String fieldName) {
31313131
}
31323132

31333133
/**
3134-
* Creates an expression that checks if the result of this expression is of the given type.
3134+
* Creates an expression that checks if the result of an expression is of the given type.
3135+
*
3136+
* <p>Supported values for {@code type} are: "null", "array", "boolean", "bytes", "timestamp",
3137+
* "geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference",
3138+
* "string", "vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
31353139
*
31363140
* @param expr The expression to check the type of.
31373141
* @param type The type to check for.
31383142
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of
31393143
* the given type, false otherwise.
31403144
*/
31413145
@BetaApi
3142-
public static BooleanExpression isType(Expression expr, Type type) {
3143-
return new BooleanFunctionExpression(
3144-
"is_type", ImmutableList.of(expr, constant(type.name().toLowerCase())));
3146+
public static BooleanExpression isType(Expression expr, String type) {
3147+
return new BooleanFunctionExpression("is_type", ImmutableList.of(expr, constant(type)));
31453148
}
31463149

31473150
/**
3148-
* Creates an expression that checks if the result of this expression is of the given type.
3151+
* Creates an expression that checks if the value of a field is of the given type.
3152+
*
3153+
* <p>Supported values for {@code type} are: "null", "array", "boolean", "bytes", "timestamp",
3154+
* "geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference",
3155+
* "string", "vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
31493156
*
31503157
* @param fieldName The name of the field to check the type of.
31513158
* @param type The type to check for.
31523159
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of
31533160
* the given type, false otherwise.
31543161
*/
31553162
@BetaApi
3156-
public static BooleanExpression isType(String fieldName, Type type) {
3163+
public static BooleanExpression isType(String fieldName, String type) {
31573164
return new BooleanFunctionExpression(
3158-
"is_type", ImmutableList.of(field(fieldName), constant(type.name().toLowerCase())));
3165+
"is_type", ImmutableList.of(field(fieldName), constant(type)));
31593166
}
31603167

31613168
// Numeric Operations
@@ -4828,12 +4835,16 @@ public final Expression type() {
48284835
/**
48294836
* Creates an expression that checks if the result of this expression is of the given type.
48304837
*
4838+
* <p>Supported values for {@code type} are: "null", "array", "boolean", "bytes", "timestamp",
4839+
* "geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference",
4840+
* "string", "vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
4841+
*
48314842
* @param type The type to check for.
48324843
* @return A new {@link BooleanExpression} that evaluates to true if the expression's result is of
48334844
* the given type, false otherwise.
48344845
*/
48354846
@BetaApi
4836-
public final Expression isType(Type type) {
4847+
public final BooleanExpression isType(String type) {
48374848
return isType(this, type);
48384849
}
48394850
}

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

Lines changed: 0 additions & 44 deletions
This file was deleted.

google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
import com.google.cloud.firestore.pipeline.expressions.AggregateFunction;
9191
import com.google.cloud.firestore.pipeline.expressions.Expression;
9292
import com.google.cloud.firestore.pipeline.expressions.Field;
93-
import com.google.cloud.firestore.pipeline.expressions.Type;
9493
import com.google.cloud.firestore.pipeline.stages.Aggregate;
9594
import com.google.cloud.firestore.pipeline.stages.AggregateHints;
9695
import com.google.cloud.firestore.pipeline.stages.AggregateOptions;
@@ -2668,26 +2667,26 @@ public void testIsType() throws Exception {
26682667
"array",
26692668
array(1, 2, true))))
26702669
.select(
2671-
Expression.isType("int", Type.INT64).as("isInt64"),
2672-
Expression.isType("int", Type.NUMBER).as("isInt64IsNumber"),
2673-
Expression.isType("int", Type.DECIMAL128).as("isInt64IsDecimal128"),
2674-
Expression.isType("float", Type.FLOAT64).as("isFloat64"),
2675-
Expression.isType("float", Type.NUMBER).as("isFloat64IsNumber"),
2676-
Expression.isType("float", Type.DECIMAL128).as("isFloat64IsDecimal128"),
2677-
Expression.isType("str", Type.STRING).as("isStr"),
2678-
Expression.isType("str", Type.INT64).as("isStrNum"),
2679-
Expression.isType("int", Type.STRING).as("isNumStr"),
2680-
Expression.isType("bool", Type.BOOLEAN).as("isBool"),
2681-
Expression.isType("null", Type.NULL).as("isNull"),
2682-
Expression.isType("geoPoint", Type.GEO_POINT).as("isGeoPoint"),
2683-
Expression.isType("timestamp", Type.TIMESTAMP).as("isTimestamp"),
2684-
Expression.isType("bytes", Type.BYTES).as("isBytes"),
2685-
Expression.isType("docRef", Type.REFERENCE).as("isDocRef"),
2686-
Expression.isType("vector", Type.VECTOR).as("isVector"),
2687-
Expression.isType("map", Type.MAP).as("isMap"),
2688-
Expression.isType("array", Type.ARRAY).as("isArray"),
2689-
Expression.isType(constant(1), Type.INT64).as("exprIsInt64"),
2690-
field("int").isType(Type.INT64).as("staticIsInt64"))
2670+
Expression.isType("int", "int64").as("isInt64"),
2671+
Expression.isType("int", "number").as("isInt64IsNumber"),
2672+
Expression.isType("int", "decimal128").as("isInt64IsDecimal128"),
2673+
Expression.isType("float", "float64").as("isFloat64"),
2674+
Expression.isType("float", "number").as("isFloat64IsNumber"),
2675+
Expression.isType("float", "decimal128").as("isFloat64IsDecimal128"),
2676+
Expression.isType("str", "string").as("isStr"),
2677+
Expression.isType("str", "int64").as("isStrNum"),
2678+
Expression.isType("int", "string").as("isNumStr"),
2679+
Expression.isType("bool", "boolean").as("isBool"),
2680+
Expression.isType("null", "null").as("isNull"),
2681+
Expression.isType("geoPoint", "geo_point").as("isGeoPoint"),
2682+
Expression.isType("timestamp", "timestamp").as("isTimestamp"),
2683+
Expression.isType("bytes", "bytes").as("isBytes"),
2684+
Expression.isType("docRef", "reference").as("isDocRef"),
2685+
Expression.isType("vector", "vector").as("isVector"),
2686+
Expression.isType("map", "map").as("isMap"),
2687+
Expression.isType("array", "array").as("isArray"),
2688+
Expression.isType(constant(1), "int64").as("exprIsInt64"),
2689+
field("int").isType("int64").as("staticIsInt64"))
26912690
.limit(1)
26922691
.execute()
26932692
.get()

0 commit comments

Comments
 (0)