@@ -27,7 +27,7 @@ import com.google.firebase.firestore.util.Preconditions
2727import com.google.firestore.v1.Pipeline
2828import com.google.firestore.v1.Value
2929
30- abstract class Stage <T : Stage <T >>
30+ abstract class BaseStage <T : BaseStage <T >>
3131internal constructor (protected val name: String , internal val options: InternalOptions ) {
3232 internal fun toProtoStage (userDataReader : UserDataReader ): Pipeline .Stage {
3333 val builder = Pipeline .Stage .newBuilder()
@@ -96,32 +96,32 @@ internal constructor(protected val name: String, internal val options: InternalO
9696 * This class provides a way to call stages that are supported by the Firestore backend but that are
9797 * not implemented in the SDK version being used.
9898 */
99- class GenericStage
99+ class Stage
100100private constructor (
101101 name: String ,
102102 private val arguments: List <GenericArg >,
103103 options: InternalOptions = InternalOptions .EMPTY
104- ) : Stage < GenericStage >(name, options) {
104+ ) : BaseStage < Stage >(name, options) {
105105 companion object {
106106 /* *
107107 * Specify name of stage
108108 *
109109 * @param name The unique name of the stage to add.
110- * @return [GenericStage ] with specified parameters.
110+ * @return [Stage ] with specified parameters.
111111 */
112- @JvmStatic fun ofName (name : String ) = GenericStage (name, emptyList(), InternalOptions .EMPTY )
112+ @JvmStatic fun ofName (name : String ) = Stage (name, emptyList(), InternalOptions .EMPTY )
113113 }
114114
115- override fun self (options : InternalOptions ) = GenericStage (name, arguments, options)
115+ override fun self (options : InternalOptions ) = Stage (name, arguments, options)
116116
117117 /* *
118118 * Specify arguments to stage.
119119 *
120120 * @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.
122122 */
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)
125125
126126 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
127127 arguments.asSequence().map { it.toProto(userDataReader) }
@@ -167,7 +167,7 @@ internal sealed class GenericArg {
167167internal class DatabaseSource
168168@JvmOverloads
169169internal constructor (options: InternalOptions = InternalOptions .EMPTY ) :
170- Stage <DatabaseSource >(" database" , options) {
170+ BaseStage <DatabaseSource >(" database" , options) {
171171 override fun self (options : InternalOptions ) = DatabaseSource (options)
172172 override fun args (userDataReader : UserDataReader ): Sequence <Value > = emptySequence()
173173}
@@ -178,7 +178,7 @@ internal constructor(
178178 // We validate [firestore.databaseId] when adding to pipeline.
179179 internal val firestore: FirebaseFirestore ? ,
180180 options: InternalOptions
181- ) : Stage <CollectionSource >(" collection" , options) {
181+ ) : BaseStage <CollectionSource >(" collection" , options) {
182182 override fun self (options : InternalOptions ): CollectionSource =
183183 CollectionSource (path, firestore, options)
184184 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
@@ -216,7 +216,7 @@ internal constructor(
216216
217217class CollectionGroupSource
218218private constructor (private val collectionId: String , options: InternalOptions ) :
219- Stage <CollectionGroupSource >(" collection_group" , options) {
219+ BaseStage <CollectionGroupSource >(" collection_group" , options) {
220220 override fun self (options : InternalOptions ) = CollectionGroupSource (collectionId, options)
221221 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
222222 sequenceOf(Value .newBuilder().setReferenceValue(" " ).build(), encodeValue(collectionId))
@@ -246,7 +246,7 @@ internal class DocumentsSource
246246internal constructor (
247247 private val documents: Array <out String >,
248248 options: InternalOptions = InternalOptions .EMPTY
249- ) : Stage <DocumentsSource >(" documents" , options) {
249+ ) : BaseStage <DocumentsSource >(" documents" , options) {
250250 internal constructor (document: String ) : this (arrayOf(document))
251251 override fun self (options : InternalOptions ) = DocumentsSource (documents, options)
252252 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
@@ -257,7 +257,7 @@ internal class AddFieldsStage
257257internal constructor (
258258 private val fields: Array <out Selectable >,
259259 options: InternalOptions = InternalOptions .EMPTY
260- ) : Stage <AddFieldsStage >(" add_fields" , options) {
260+ ) : BaseStage <AddFieldsStage >(" add_fields" , options) {
261261 override fun self (options : InternalOptions ) = AddFieldsStage (fields, options)
262262 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
263263 sequenceOf(encodeValue(fields.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -284,7 +284,7 @@ internal constructor(
284284 private val accumulators: Map <String , AggregateFunction >,
285285 private val groups: Map <String , Expr >,
286286 options: InternalOptions = InternalOptions .EMPTY
287- ) : Stage <AggregateStage >(" aggregate" , options) {
287+ ) : BaseStage <AggregateStage >(" aggregate" , options) {
288288 private constructor (accumulators: Map <String , AggregateFunction >) : this (accumulators, emptyMap())
289289 companion object {
290290
@@ -349,7 +349,7 @@ internal class WhereStage
349349internal constructor (
350350 private val condition: BooleanExpr ,
351351 options: InternalOptions = InternalOptions .EMPTY
352- ) : Stage <WhereStage >(" where" , options) {
352+ ) : BaseStage <WhereStage >(" where" , options) {
353353 override fun self (options : InternalOptions ) = WhereStage (condition, options)
354354 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
355355 sequenceOf(condition.toProto(userDataReader))
@@ -365,7 +365,7 @@ internal constructor(
365365 private val vector: Expr ,
366366 private val distanceMeasure: DistanceMeasure ,
367367 options: InternalOptions = InternalOptions .EMPTY
368- ) : Stage <FindNearestStage >(" find_nearest" , options) {
368+ ) : BaseStage <FindNearestStage >(" find_nearest" , options) {
369369
370370 companion object {
371371
@@ -477,15 +477,15 @@ internal constructor(
477477
478478internal class LimitStage
479479internal constructor (private val limit: Int , options: InternalOptions = InternalOptions .EMPTY ) :
480- Stage <LimitStage >(" limit" , options) {
480+ BaseStage <LimitStage >(" limit" , options) {
481481 override fun self (options : InternalOptions ) = LimitStage (limit, options)
482482 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
483483 sequenceOf(encodeValue(limit))
484484}
485485
486486internal class OffsetStage
487487internal constructor (private val offset: Int , options: InternalOptions = InternalOptions .EMPTY ) :
488- Stage <OffsetStage >(" offset" , options) {
488+ BaseStage <OffsetStage >(" offset" , options) {
489489 override fun self (options : InternalOptions ) = OffsetStage (offset, options)
490490 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
491491 sequenceOf(encodeValue(offset))
@@ -495,7 +495,7 @@ internal class SelectStage
495495internal constructor (
496496 private val fields: Array <out Selectable >,
497497 options: InternalOptions = InternalOptions .EMPTY
498- ) : Stage <SelectStage >(" select" , options) {
498+ ) : BaseStage <SelectStage >(" select" , options) {
499499 override fun self (options : InternalOptions ) = SelectStage (fields, options)
500500 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
501501 sequenceOf(encodeValue(fields.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -505,7 +505,7 @@ internal class SortStage
505505internal constructor (
506506 private val orders: Array <out Ordering >,
507507 options: InternalOptions = InternalOptions .EMPTY
508- ) : Stage <SortStage >(" sort" , options) {
508+ ) : BaseStage <SortStage >(" sort" , options) {
509509 override fun self (options : InternalOptions ) = SortStage (orders, options)
510510 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
511511 orders.asSequence().map { it.toProto(userDataReader) }
@@ -515,7 +515,7 @@ internal class DistinctStage
515515internal constructor (
516516 private val groups: Array <out Selectable >,
517517 options: InternalOptions = InternalOptions .EMPTY
518- ) : Stage <DistinctStage >(" distinct" , options) {
518+ ) : BaseStage <DistinctStage >(" distinct" , options) {
519519 override fun self (options : InternalOptions ) = DistinctStage (groups, options)
520520 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
521521 sequenceOf(encodeValue(groups.associate { it.getAlias() to it.toProto(userDataReader) }))
@@ -525,7 +525,7 @@ internal class RemoveFieldsStage
525525internal constructor (
526526 private val fields: Array <out Field >,
527527 options: InternalOptions = InternalOptions .EMPTY
528- ) : Stage <RemoveFieldsStage >(" remove_fields" , options) {
528+ ) : BaseStage <RemoveFieldsStage >(" remove_fields" , options) {
529529 override fun self (options : InternalOptions ) = RemoveFieldsStage (fields, options)
530530 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
531531 fields.asSequence().map(Field ::toProto)
@@ -536,7 +536,7 @@ internal constructor(
536536 private val mapValue: Expr ,
537537 private val mode: Mode ,
538538 options: InternalOptions = InternalOptions .EMPTY
539- ) : Stage <ReplaceStage >(" replace" , options) {
539+ ) : BaseStage <ReplaceStage >(" replace" , options) {
540540 class Mode private constructor(internal val proto : Value ) {
541541 private constructor (protoString: String ) : this (encodeValue(protoString))
542542 companion object {
@@ -563,7 +563,7 @@ private constructor(
563563 private val size: Number ,
564564 private val mode: Mode ,
565565 options: InternalOptions = InternalOptions .EMPTY
566- ) : Stage <SampleStage >(" sample" , options) {
566+ ) : BaseStage <SampleStage >(" sample" , options) {
567567 override fun self (options : InternalOptions ) = SampleStage (size, mode, options)
568568 class Mode private constructor(internal val proto : Value ) {
569569 private constructor (protoString: String ) : this (encodeValue(protoString))
@@ -606,7 +606,7 @@ internal class UnionStage
606606internal constructor (
607607 private val other: com.google.firebase.firestore.Pipeline ,
608608 options: InternalOptions = InternalOptions .EMPTY
609- ) : Stage <UnionStage >(" union" , options) {
609+ ) : BaseStage <UnionStage >(" union" , options) {
610610 override fun self (options : InternalOptions ) = UnionStage (other, options)
611611 override fun args (userDataReader : UserDataReader ): Sequence <Value > =
612612 sequenceOf(Value .newBuilder().setPipelineValue(other.toPipelineProto()).build())
@@ -620,7 +620,7 @@ class UnnestStage
620620internal constructor (
621621 private val selectable: Selectable ,
622622 options: InternalOptions = InternalOptions .EMPTY
623- ) : Stage <UnnestStage >(" unnest" , options) {
623+ ) : BaseStage <UnnestStage >(" unnest" , options) {
624624 companion object {
625625
626626 /* *
0 commit comments