Skip to content

Commit 736967e

Browse files
committed
Small fixes to expressions
1 parent c010b5e commit 736967e

File tree

1 file changed

+16
-20
lines changed
  • firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline

1 file changed

+16
-20
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ abstract class Expr internal constructor() {
240240
* @return A new [Expr] constant instance.
241241
*/
242242
@JvmStatic
243-
fun constant(value: VectorValue): Expr {
244-
return Constant(encodeValue(value))
245-
}
243+
fun constant(value: VectorValue): Expr = Constant(encodeValue(value))
246244

247245
/**
248246
* Create a [Blob] constant from a [ByteArray].
@@ -251,19 +249,15 @@ abstract class Expr internal constructor() {
251249
* @return A new [Expr] constant instance representing the Blob.
252250
*/
253251
@JvmStatic
254-
fun blob(bytes: ByteArray): Expr {
255-
return constant(Blob.fromBytes(bytes))
256-
}
252+
fun blob(bytes: ByteArray): Expr = constant(Blob.fromBytes(bytes))
257253

258254
/**
259255
* Constant for a null value.
260256
*
261257
* @return A [Expr] constant instance.
262258
*/
263259
@JvmStatic
264-
fun nullValue(): Expr {
265-
return NULL
266-
}
260+
fun nullValue(): Expr = NULL
267261

268262
/**
269263
* Create a vector constant for a [DoubleArray] value.
@@ -272,9 +266,7 @@ abstract class Expr internal constructor() {
272266
* @return A [Expr] constant instance.
273267
*/
274268
@JvmStatic
275-
fun vector(vector: DoubleArray): Expr {
276-
return Constant(Values.encodeVectorValue(vector))
277-
}
269+
fun vector(vector: DoubleArray): Expr = Constant(Values.encodeVectorValue(vector))
278270

279271
/**
280272
* Create a vector constant for a [VectorValue] value.
@@ -283,9 +275,7 @@ abstract class Expr internal constructor() {
283275
* @return A [Expr] constant instance.
284276
*/
285277
@JvmStatic
286-
fun vector(vector: VectorValue): Expr {
287-
return Constant(encodeValue(vector))
288-
}
278+
fun vector(vector: VectorValue): Expr = Constant(encodeValue(vector))
289279

290280
/**
291281
* Creates a [Field] instance representing the field at the given path.
@@ -316,9 +306,7 @@ abstract class Expr internal constructor() {
316306
* @return A new [Field] instance representing the specified path.
317307
*/
318308
@JvmStatic
319-
fun field(fieldPath: FieldPath): Field {
320-
return Field(fieldPath.internalPath)
321-
}
309+
fun field(fieldPath: FieldPath): Field = Field(fieldPath.internalPath)
322310

323311
@JvmStatic
324312
fun generic(name: String, vararg expr: Expr): Expr = FunctionExpr(name, notImplemented, expr)
@@ -3625,6 +3613,14 @@ abstract class Expr internal constructor() {
36253613
*/
36263614
fun strConcat(vararg strings: Any): Expr = Companion.strConcat(this, *strings)
36273615

3616+
/**
3617+
* Accesses a map (object) value using the provided [keyExpression].
3618+
*
3619+
* @param keyExpression The name of the key to remove from this map expression.
3620+
* @return A new [Expr] representing the value associated with the given key in the map.
3621+
*/
3622+
fun mapGet(keyExpression: Expr) = Companion.mapGet(this, keyExpression)
3623+
36283624
/**
36293625
* Accesses a map (object) value using the provided [key].
36303626
*
@@ -3647,10 +3643,10 @@ abstract class Expr internal constructor() {
36473643
/**
36483644
* Creates an expression that removes a key from this map expression.
36493645
*
3650-
* @param key The name of the key to remove from this map expression.
3646+
* @param keyExpression The name of the key to remove from this map expression.
36513647
* @return A new [Expr] that evaluates to a modified map.
36523648
*/
3653-
fun mapRemove(key: Expr) = Companion.mapRemove(this, key)
3649+
fun mapRemove(keyExpression: Expr) = Companion.mapRemove(this, keyExpression)
36543650

36553651
/**
36563652
* Creates an expression that removes a key from this map expression.

0 commit comments

Comments
 (0)