@@ -27,7 +27,7 @@ import com.google.firebase.firestore.util.Preconditions
27
27
import com.google.firestore.v1.Pipeline
28
28
import com.google.firestore.v1.Value
29
29
30
- abstract class Stage <T : Stage <T >>
30
+ abstract class BaseStage <T : BaseStage <T >>
31
31
internal constructor (protected val name: String , internal val options: InternalOptions ) {
32
32
internal fun toProtoStage (userDataReader : UserDataReader ): Pipeline .Stage {
33
33
val builder = Pipeline .Stage .newBuilder()
@@ -96,32 +96,32 @@ internal constructor(protected val name: String, internal val options: InternalO
96
96
* This class provides a way to call stages that are supported by the Firestore backend but that are
97
97
* not implemented in the SDK version being used.
98
98
*/
99
- class GenericStage
99
+ class Stage
100
100
private constructor (
101
101
name: String ,
102
102
private val arguments: List <GenericArg >,
103
103
options: InternalOptions = InternalOptions .EMPTY
104
- ) : Stage < GenericStage >(name, options) {
104
+ ) : BaseStage < Stage >(name, options) {
105
105
companion object {
106
106
/* *
107
107
* Specify name of stage
108
108
*
109
109
* @param name The unique name of the stage to add.
110
- * @return [GenericStage ] with specified parameters.
110
+ * @return [Stage ] with specified parameters.
111
111
*/
112
- @JvmStatic fun ofName (name : String ) = GenericStage (name, emptyList(), InternalOptions .EMPTY )
112
+ @JvmStatic fun ofName (name : String ) = Stage (name, emptyList(), InternalOptions .EMPTY )
113
113
}
114
114
115
- override fun self (options : InternalOptions ) = GenericStage (name, arguments, options)
115
+ override fun self (options : InternalOptions ) = Stage (name, arguments, options)
116
116
117
117
/* *
118
118
* Specify arguments to stage.
119
119
*
120
120
* @param arguments A list of ordered parameters to configure the stage's behavior.
121
- * @return [GenericStage ] with specified parameters.
121
+ * @return [Stage ] with specified parameters.
122
122
*/
123
- fun withArguments (vararg arguments : Any ): GenericStage =
124
- GenericStage (name, arguments.map(GenericArg ::from), options)
123
+ fun withArguments (vararg arguments : Any ): Stage =
124
+ Stage (name, arguments.map(GenericArg ::from), options)
125
125
126
126
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
127
127
arguments.asSequence().map { it.toProto(userDataReader) }
@@ -167,7 +167,7 @@ internal sealed class GenericArg {
167
167
internal class DatabaseSource
168
168
@JvmOverloads
169
169
internal constructor (options: InternalOptions = InternalOptions .EMPTY ) :
170
- Stage <DatabaseSource >(" database" , options) {
170
+ BaseStage <DatabaseSource >(" database" , options) {
171
171
override fun self (options : InternalOptions ) = DatabaseSource (options)
172
172
override fun args (userDataReader : UserDataReader ): Sequence <Value > = emptySequence()
173
173
}
@@ -178,7 +178,7 @@ internal constructor(
178
178
// We validate [firestore.databaseId] when adding to pipeline.
179
179
internal val firestore: FirebaseFirestore ? ,
180
180
options: InternalOptions
181
- ) : Stage <CollectionSource >(" collection" , options) {
181
+ ) : BaseStage <CollectionSource >(" collection" , options) {
182
182
override fun self (options : InternalOptions ): CollectionSource =
183
183
CollectionSource (path, firestore, options)
184
184
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
@@ -216,7 +216,7 @@ internal constructor(
216
216
217
217
class CollectionGroupSource
218
218
private constructor (private val collectionId: String , options: InternalOptions ) :
219
- Stage <CollectionGroupSource >(" collection_group" , options) {
219
+ BaseStage <CollectionGroupSource >(" collection_group" , options) {
220
220
override fun self (options : InternalOptions ) = CollectionGroupSource (collectionId, options)
221
221
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
222
222
sequenceOf(Value .newBuilder().setReferenceValue(" " ).build(), encodeValue(collectionId))
@@ -246,7 +246,7 @@ internal class DocumentsSource
246
246
internal constructor (
247
247
private val documents: Array <out String >,
248
248
options: InternalOptions = InternalOptions .EMPTY
249
- ) : Stage <DocumentsSource >(" documents" , options) {
249
+ ) : BaseStage <DocumentsSource >(" documents" , options) {
250
250
internal constructor (document: String ) : this (arrayOf(document))
251
251
override fun self (options : InternalOptions ) = DocumentsSource (documents, options)
252
252
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
@@ -257,7 +257,7 @@ internal class AddFieldsStage
257
257
internal constructor (
258
258
private val fields: Array <out Selectable >,
259
259
options: InternalOptions = InternalOptions .EMPTY
260
- ) : Stage <AddFieldsStage >(" add_fields" , options) {
260
+ ) : BaseStage <AddFieldsStage >(" add_fields" , options) {
261
261
override fun self (options : InternalOptions ) = AddFieldsStage (fields, options)
262
262
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
263
263
sequenceOf(encodeValue(fields.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -284,7 +284,7 @@ internal constructor(
284
284
private val accumulators: Map <String , AggregateFunction >,
285
285
private val groups: Map <String , Expr >,
286
286
options: InternalOptions = InternalOptions .EMPTY
287
- ) : Stage <AggregateStage >(" aggregate" , options) {
287
+ ) : BaseStage <AggregateStage >(" aggregate" , options) {
288
288
private constructor (accumulators: Map <String , AggregateFunction >) : this (accumulators, emptyMap())
289
289
companion object {
290
290
@@ -349,7 +349,7 @@ internal class WhereStage
349
349
internal constructor (
350
350
private val condition: BooleanExpr ,
351
351
options: InternalOptions = InternalOptions .EMPTY
352
- ) : Stage <WhereStage >(" where" , options) {
352
+ ) : BaseStage <WhereStage >(" where" , options) {
353
353
override fun self (options : InternalOptions ) = WhereStage (condition, options)
354
354
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
355
355
sequenceOf(condition.toProto(userDataReader))
@@ -365,7 +365,7 @@ internal constructor(
365
365
private val vector: Expr ,
366
366
private val distanceMeasure: DistanceMeasure ,
367
367
options: InternalOptions = InternalOptions .EMPTY
368
- ) : Stage <FindNearestStage >(" find_nearest" , options) {
368
+ ) : BaseStage <FindNearestStage >(" find_nearest" , options) {
369
369
370
370
companion object {
371
371
@@ -477,15 +477,15 @@ internal constructor(
477
477
478
478
internal class LimitStage
479
479
internal constructor (private val limit: Int , options: InternalOptions = InternalOptions .EMPTY ) :
480
- Stage <LimitStage >(" limit" , options) {
480
+ BaseStage <LimitStage >(" limit" , options) {
481
481
override fun self (options : InternalOptions ) = LimitStage (limit, options)
482
482
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
483
483
sequenceOf(encodeValue(limit))
484
484
}
485
485
486
486
internal class OffsetStage
487
487
internal constructor (private val offset: Int , options: InternalOptions = InternalOptions .EMPTY ) :
488
- Stage <OffsetStage >(" offset" , options) {
488
+ BaseStage <OffsetStage >(" offset" , options) {
489
489
override fun self (options : InternalOptions ) = OffsetStage (offset, options)
490
490
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
491
491
sequenceOf(encodeValue(offset))
@@ -495,7 +495,7 @@ internal class SelectStage
495
495
internal constructor (
496
496
private val fields: Array <out Selectable >,
497
497
options: InternalOptions = InternalOptions .EMPTY
498
- ) : Stage <SelectStage >(" select" , options) {
498
+ ) : BaseStage <SelectStage >(" select" , options) {
499
499
override fun self (options : InternalOptions ) = SelectStage (fields, options)
500
500
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
501
501
sequenceOf(encodeValue(fields.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -505,7 +505,7 @@ internal class SortStage
505
505
internal constructor (
506
506
private val orders: Array <out Ordering >,
507
507
options: InternalOptions = InternalOptions .EMPTY
508
- ) : Stage <SortStage >(" sort" , options) {
508
+ ) : BaseStage <SortStage >(" sort" , options) {
509
509
override fun self (options : InternalOptions ) = SortStage (orders, options)
510
510
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
511
511
orders.asSequence().map { it.toProto(userDataReader) }
@@ -515,7 +515,7 @@ internal class DistinctStage
515
515
internal constructor (
516
516
private val groups: Array <out Selectable >,
517
517
options: InternalOptions = InternalOptions .EMPTY
518
- ) : Stage <DistinctStage >(" distinct" , options) {
518
+ ) : BaseStage <DistinctStage >(" distinct" , options) {
519
519
override fun self (options : InternalOptions ) = DistinctStage (groups, options)
520
520
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
521
521
sequenceOf(encodeValue(groups.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -525,7 +525,7 @@ internal class RemoveFieldsStage
525
525
internal constructor (
526
526
private val fields: Array <out Field >,
527
527
options: InternalOptions = InternalOptions .EMPTY
528
- ) : Stage <RemoveFieldsStage >(" remove_fields" , options) {
528
+ ) : BaseStage <RemoveFieldsStage >(" remove_fields" , options) {
529
529
override fun self (options : InternalOptions ) = RemoveFieldsStage (fields, options)
530
530
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
531
531
fields.asSequence().map(Field ::toProto)
@@ -536,7 +536,7 @@ internal constructor(
536
536
private val mapValue: Expr ,
537
537
private val mode: Mode ,
538
538
options: InternalOptions = InternalOptions .EMPTY
539
- ) : Stage <ReplaceStage >(" replace" , options) {
539
+ ) : BaseStage <ReplaceStage >(" replace" , options) {
540
540
class Mode private constructor(internal val proto : Value ) {
541
541
private constructor (protoString: String ) : this (encodeValue(protoString))
542
542
companion object {
@@ -563,7 +563,7 @@ private constructor(
563
563
private val size: Number ,
564
564
private val mode: Mode ,
565
565
options: InternalOptions = InternalOptions .EMPTY
566
- ) : Stage <SampleStage >(" sample" , options) {
566
+ ) : BaseStage <SampleStage >(" sample" , options) {
567
567
override fun self (options : InternalOptions ) = SampleStage (size, mode, options)
568
568
class Mode private constructor(internal val proto : Value ) {
569
569
private constructor (protoString: String ) : this (encodeValue(protoString))
@@ -606,7 +606,7 @@ internal class UnionStage
606
606
internal constructor (
607
607
private val other: com.google.firebase.firestore.Pipeline ,
608
608
options: InternalOptions = InternalOptions .EMPTY
609
- ) : Stage <UnionStage >(" union" , options) {
609
+ ) : BaseStage <UnionStage >(" union" , options) {
610
610
override fun self (options : InternalOptions ) = UnionStage (other, options)
611
611
override fun args (userDataReader : UserDataReader ): Sequence <Value > =
612
612
sequenceOf(Value .newBuilder().setPipelineValue(other.toPipelineProto()).build())
@@ -620,7 +620,7 @@ class UnnestStage
620
620
internal constructor (
621
621
private val selectable: Selectable ,
622
622
options: InternalOptions = InternalOptions .EMPTY
623
- ) : Stage <UnnestStage >(" unnest" , options) {
623
+ ) : BaseStage <UnnestStage >(" unnest" , options) {
624
624
companion object {
625
625
626
626
/* *
0 commit comments