Skip to content

Commit 8817f81

Browse files
committed
More expression work
1 parent 8a81354 commit 8817f81

File tree

1 file changed

+99
-30
lines changed
  • firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline

1 file changed

+99
-30
lines changed

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

Lines changed: 99 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,23 +1512,43 @@ abstract class Expr internal constructor() {
15121512
/**
15131513
* Creates an expression that checks if a string expression contains a specified substring.
15141514
*
1515+
* @param stringExpression The expression representing the string to perform the comparison on.
1516+
* @param substring The expression representing the substring to search for.
15151517
* @return A new [BooleanExpr] representing the contains comparison.
15161518
*/
15171519
@JvmStatic
1518-
fun strContains(expr: Expr, substring: Expr): BooleanExpr =
1519-
BooleanExpr("str_contains", expr, substring)
1520+
fun strContains(stringExpression: Expr, substring: Expr): BooleanExpr =
1521+
BooleanExpr("str_contains", stringExpression, substring)
15201522

1521-
/** @return A new [Expr] representing the strContains operation. */
1523+
/**
1524+
* Creates an expression that checks if a string expression contains a specified substring.
1525+
*
1526+
* @param stringExpression The expression representing the string to perform the comparison on.
1527+
* @param substring The substring to search for.
1528+
* @return A new [BooleanExpr] representing the contains comparison.
1529+
*/
15221530
@JvmStatic
1523-
fun strContains(expr: Expr, substring: String): BooleanExpr =
1524-
BooleanExpr("str_contains", expr, substring)
1531+
fun strContains(stringExpression: Expr, substring: String): BooleanExpr =
1532+
BooleanExpr("str_contains", stringExpression, substring)
15251533

1526-
/** @return A new [BooleanExpr] representing the strContains operation. */
1534+
/**
1535+
* Creates an expression that checks if a string field contains a specified substring.
1536+
*
1537+
* @param fieldName The name of the field to perform the comparison on.
1538+
* @param substring The expression representing the substring to search for.
1539+
* @return A new [BooleanExpr] representing the contains comparison.
1540+
*/
15271541
@JvmStatic
15281542
fun strContains(fieldName: String, substring: Expr): BooleanExpr =
15291543
BooleanExpr("str_contains", fieldName, substring)
15301544

1531-
/** @return A new [BooleanExpr] representing the strContains operation. */
1545+
/**
1546+
* Creates an expression that checks if a string field contains a specified substring.
1547+
*
1548+
* @param fieldName The name of the field to perform the comparison on.
1549+
* @param substring The substring to search for.
1550+
* @return A new [BooleanExpr] representing the contains comparison.
1551+
*/
15321552
@JvmStatic
15331553
fun strContains(fieldName: String, substring: String): BooleanExpr =
15341554
BooleanExpr("str_contains", fieldName, substring)
@@ -1645,23 +1665,51 @@ abstract class Expr internal constructor() {
16451665
/** @return A new [Expr] representing the trim operation. */
16461666
@JvmStatic fun trim(fieldName: String): Expr = FunctionExpr("trim", fieldName)
16471667

1648-
/** @return A new [Expr] representing the strConcat operation. */
1668+
/**
1669+
* Creates an expression that concatenates string expressions together.
1670+
*
1671+
* @param firstString The expression representing the initial string value.
1672+
* @param otherStrings Optional additional string expressions to concatenate.
1673+
* @return A new [Expr] representing the concatenated string.
1674+
*/
16491675
@JvmStatic
1650-
fun strConcat(first: Expr, vararg rest: Expr): Expr = FunctionExpr("str_concat", first, *rest)
1676+
fun strConcat(firstString: Expr, vararg otherStrings: Expr): Expr =
1677+
FunctionExpr("str_concat", firstString, *otherStrings)
16511678

1652-
/** @return A new [Expr] representing the strConcat operation. */
1679+
/**
1680+
* Creates an expression that concatenates string expressions together.
1681+
*
1682+
* @param firstString The expression representing the initial string value.
1683+
* @param otherStrings Optional additional string expressions or string constants to
1684+
* concatenate.
1685+
* @return A new [Expr] representing the concatenated string.
1686+
*/
16531687
@JvmStatic
1654-
fun strConcat(first: Expr, vararg rest: Any): Expr = FunctionExpr("str_concat", first, *rest)
1688+
fun strConcat(firstString: Expr, vararg otherStrings: Any): Expr =
1689+
FunctionExpr("str_concat", firstString, *otherStrings)
16551690

1656-
/** @return A new [Expr] representing the strConcat operation. */
1691+
/**
1692+
* Creates an expression that concatenates string expressions together.
1693+
*
1694+
* @param fieldName The field name containing the initial string value.
1695+
* @param otherStrings Optional additional string expressions to concatenate.
1696+
* @return A new [Expr] representing the concatenated string.
1697+
*/
16571698
@JvmStatic
1658-
fun strConcat(fieldName: String, vararg rest: Expr): Expr =
1659-
FunctionExpr("str_concat", fieldName, *rest)
1699+
fun strConcat(fieldName: String, vararg otherStrings: Expr): Expr =
1700+
FunctionExpr("str_concat", fieldName, *otherStrings)
16601701

1661-
/** @return A new [Expr] representing the strConcat operation. */
1702+
/**
1703+
* Creates an expression that concatenates string expressions together.
1704+
*
1705+
* @param fieldName The field name containing the initial string value.
1706+
* @param otherStrings Optional additional string expressions or string constants to
1707+
* concatenate.
1708+
* @return A new [Expr] representing the concatenated string.
1709+
*/
16621710
@JvmStatic
1663-
fun strConcat(fieldName: String, vararg rest: Any): Expr =
1664-
FunctionExpr("str_concat", fieldName, *rest)
1711+
fun strConcat(fieldName: String, vararg otherStrings: Any): Expr =
1712+
FunctionExpr("str_concat", fieldName, *otherStrings)
16651713

16661714
internal fun map(elements: Array<out Expr>): Expr = FunctionExpr("map", elements)
16671715

@@ -2776,7 +2824,7 @@ abstract class Expr internal constructor() {
27762824
* @param others Additional numeric expressions or constants to add.
27772825
* @return A new [Expr] representing the addition operation.
27782826
*/
2779-
fun add(second: Expr, vararg others: Any) = Companion.add(this, second, *others)
2827+
fun add(second: Expr, vararg others: Any): Expr = Companion.add(this, second, *others)
27802828

27812829
/**
27822830
* Creates an expression that adds this numeric expression to other numeric expressions and
@@ -2786,23 +2834,23 @@ abstract class Expr internal constructor() {
27862834
* @param others Additional numeric expressions or constants to add.
27872835
* @return A new [Expr] representing the addition operation.
27882836
*/
2789-
fun add(second: Number, vararg others: Any) = Companion.add(this, second, *others)
2837+
fun add(second: Number, vararg others: Any): Expr = Companion.add(this, second, *others)
27902838

27912839
/**
27922840
* Creates an expression that subtracts a constant from this numeric expression.
27932841
*
27942842
* @param subtrahend Numeric expression to subtract.
27952843
* @return A new [Expr] representing the subtract operation.
27962844
*/
2797-
fun subtract(subtrahend: Expr) = Companion.subtract(this, subtrahend)
2845+
fun subtract(subtrahend: Expr): Expr = Companion.subtract(this, subtrahend)
27982846

27992847
/**
28002848
* Creates an expression that subtracts a numeric expressions from this numeric expression.
28012849
*
28022850
* @param subtrahend Constant to subtract.
28032851
* @return A new [Expr] representing the subtract operation.
28042852
*/
2805-
fun subtract(subtrahend: Number) = Companion.subtract(this, subtrahend)
2853+
fun subtract(subtrahend: Number): Expr = Companion.subtract(this, subtrahend)
28062854

28072855
/**
28082856
* Creates an expression that multiplies this numeric expression to other numeric expressions and
@@ -2812,7 +2860,7 @@ abstract class Expr internal constructor() {
28122860
* @param others Additional numeric expressions or constants to multiply.
28132861
* @return A new [Expr] representing the multiplication operation.
28142862
*/
2815-
fun multiply(second: Expr, vararg others: Any) = Companion.multiply(this, second, *others)
2863+
fun multiply(second: Expr, vararg others: Any): Expr = Companion.multiply(this, second, *others)
28162864

28172865
/**
28182866
* Creates an expression that multiplies this numeric expression to other numeric expressions and
@@ -2822,23 +2870,23 @@ abstract class Expr internal constructor() {
28222870
* @param others Additional numeric expressions or constants to multiply.
28232871
* @return A new [Expr] representing the multiplication operation.
28242872
*/
2825-
fun multiply(second: Number, vararg others: Any) = Companion.multiply(this, second, *others)
2873+
fun multiply(second: Number, vararg others: Any): Expr = Companion.multiply(this, second, *others)
28262874

28272875
/**
28282876
* Creates an expression that divides this numeric expression by another numeric expression.
28292877
*
28302878
* @param divisor Numeric expression to divide this numeric expression by.
28312879
* @return A new [Expr] representing the division operation.
28322880
*/
2833-
fun divide(divisor: Expr) = Companion.divide(this, divisor)
2881+
fun divide(divisor: Expr): Expr = Companion.divide(this, divisor)
28342882

28352883
/**
28362884
* Creates an expression that divides this numeric expression by a constant.
28372885
*
28382886
* @param divisor Constant to divide this expression by.
28392887
* @return A new [Expr] representing the division operation.
28402888
*/
2841-
fun divide(divisor: Number) = Companion.divide(this, divisor)
2889+
fun divide(divisor: Number): Expr = Companion.divide(this, divisor)
28422890

28432891
/**
28442892
* Creates an expression that calculates the modulo (remainder) of dividing this numeric
@@ -2847,7 +2895,7 @@ abstract class Expr internal constructor() {
28472895
* @param divisor The numeric expression to divide this expression by.
28482896
* @return A new [Expr] representing the modulo operation.
28492897
*/
2850-
fun mod(divisor: Expr) = Companion.mod(this, divisor)
2898+
fun mod(divisor: Expr): Expr = Companion.mod(this, divisor)
28512899

28522900
/**
28532901
* Creates an expression that calculates the modulo (remainder) of dividing this numeric
@@ -2856,7 +2904,7 @@ abstract class Expr internal constructor() {
28562904
* @param divisor The constant to divide this expression by.
28572905
* @return A new [Expr] representing the modulo operation.
28582906
*/
2859-
fun mod(divisor: Number) = Companion.mod(this, divisor)
2907+
fun mod(divisor: Number): Expr = Companion.mod(this, divisor)
28602908

28612909
/**
28622910
* Creates an expression that rounds this numeric expression to nearest integer.
@@ -3156,10 +3204,18 @@ abstract class Expr internal constructor() {
31563204
fun reverse(): Expr = Companion.reverse(this)
31573205

31583206
/**
3207+
* Creates an expression that checks if this string expression contains a specified substring.
3208+
*
3209+
* @param substring The expression representing the substring to search for.
3210+
* @return A new [BooleanExpr] representing the contains comparison.
31593211
*/
31603212
fun strContains(substring: Expr): BooleanExpr = Companion.strContains(this, substring)
31613213

31623214
/**
3215+
* Creates an expression that checks if this string expression contains a specified substring.
3216+
*
3217+
* @param substring The substring to search for.
3218+
* @return A new [BooleanExpr] representing the contains comparison.
31633219
*/
31643220
fun strContains(substring: String): BooleanExpr = Companion.strContains(this, substring)
31653221

@@ -3208,16 +3264,29 @@ abstract class Expr internal constructor() {
32083264
fun trim() = Companion.trim(this)
32093265

32103266
/**
3267+
* Creates an expression that concatenates string expressions together.
3268+
*
3269+
* @param stringExpressions The string expressions to concatenate.
3270+
* @return A new [Expr] representing the concatenated string.
32113271
*/
3212-
fun strConcat(vararg expr: Expr) = Companion.strConcat(this, *expr)
3272+
fun strConcat(vararg stringExpressions: Expr): Expr =
3273+
Companion.strConcat(this, *stringExpressions)
32133274

32143275
/**
3276+
* Creates an expression that concatenates this string expression with string constants.
3277+
*
3278+
* @param strings The string constants to concatenate.
3279+
* @return A new [Expr] representing the concatenated string.
32153280
*/
3216-
fun strConcat(vararg string: String) = Companion.strConcat(this, *string)
3281+
fun strConcat(vararg strings: String): Expr = Companion.strConcat(this, *strings)
32173282

32183283
/**
3284+
* Creates an expression that concatenates string expressions and string constants together.
3285+
*
3286+
* @param strings The string expressions or string constants to concatenate.
3287+
* @return A new [Expr] representing the concatenated string.
32193288
*/
3220-
fun strConcat(vararg string: Any) = Companion.strConcat(this, *string)
3289+
fun strConcat(vararg strings: Any): Expr = Companion.strConcat(this, *strings)
32213290

32223291
/**
32233292
* Accesses a map (object) value using the provided [key].

0 commit comments

Comments
 (0)