Skip to content

Commit 6369f3c

Browse files
committed
rename generic stage
1 parent 065235f commit 6369f3c

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import com.google.firebase.firestore.pipeline.AggregateFunction;
4848
import com.google.firebase.firestore.pipeline.AggregateStage;
4949
import com.google.firebase.firestore.pipeline.Expr;
50-
import com.google.firebase.firestore.pipeline.GenericStage;
50+
import com.google.firebase.firestore.pipeline.Stage;
5151
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
5252
import java.util.Collections;
5353
import java.util.LinkedHashMap;
@@ -279,15 +279,15 @@ public void groupAndAccumulateResultsGeneric() {
279279
firestore
280280
.pipeline()
281281
.collection(randomCol)
282-
.genericStage(GenericStage.ofName("where").withArguments(lt(field("published"), 1984)))
283-
.genericStage(
284-
GenericStage.ofName("aggregate")
282+
.addStage(Stage.ofName("where").withArguments(lt(field("published"), 1984)))
283+
.addStage(
284+
Stage.ofName("aggregate")
285285
.withArguments(
286286
ImmutableMap.of("avgRating", AggregateFunction.avg("rating")),
287287
ImmutableMap.of("genre", field("genre"))))
288-
.genericStage(GenericStage.ofName("where").withArguments(gt("avgRating", 4.3)))
289-
.genericStage(
290-
GenericStage.ofName("sort").withArguments(field("avgRating").descending()))
288+
.addStage(Stage.ofName("where").withArguments(gt("avgRating", 4.3)))
289+
.addStage(
290+
Stage.ofName("sort").withArguments(field("avgRating").descending()))
291291
.execute();
292292
assertThat(waitFor(execute).getResults())
293293
.comparingElementsUsing(DATA_CORRESPONDENCE)

firebase-firestore/src/main/java/com/google/firebase/firestore/Pipeline.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import com.google.firebase.firestore.pipeline.ExprWithAlias
3636
import com.google.firebase.firestore.pipeline.Field
3737
import com.google.firebase.firestore.pipeline.FindNearestStage
3838
import com.google.firebase.firestore.pipeline.FunctionExpr
39-
import com.google.firebase.firestore.pipeline.GenericStage
39+
import com.google.firebase.firestore.pipeline.Stage
4040
import com.google.firebase.firestore.pipeline.LimitStage
4141
import com.google.firebase.firestore.pipeline.OffsetStage
4242
import com.google.firebase.firestore.pipeline.Ordering
@@ -47,7 +47,7 @@ import com.google.firebase.firestore.pipeline.SampleStage
4747
import com.google.firebase.firestore.pipeline.SelectStage
4848
import com.google.firebase.firestore.pipeline.Selectable
4949
import com.google.firebase.firestore.pipeline.SortStage
50-
import com.google.firebase.firestore.pipeline.Stage
50+
import com.google.firebase.firestore.pipeline.BaseStage
5151
import com.google.firebase.firestore.pipeline.UnionStage
5252
import com.google.firebase.firestore.pipeline.UnnestStage
5353
import com.google.firebase.firestore.pipeline.WhereStage
@@ -59,15 +59,15 @@ class Pipeline
5959
internal constructor(
6060
internal val firestore: FirebaseFirestore,
6161
internal val userDataReader: UserDataReader,
62-
private val stages: FluentIterable<Stage<*>>
62+
private val stages: FluentIterable<BaseStage<*>>
6363
) {
6464
internal constructor(
6565
firestore: FirebaseFirestore,
6666
userDataReader: UserDataReader,
67-
stage: Stage<*>
67+
stage: BaseStage<*>
6868
) : this(firestore, userDataReader, FluentIterable.of(stage))
6969

70-
private fun append(stage: Stage<*>): Pipeline {
70+
private fun append(stage: BaseStage<*>): Pipeline {
7171
return Pipeline(firestore, userDataReader, stages.append(stage))
7272
}
7373

@@ -110,10 +110,10 @@ internal constructor(
110110
* This method provides a way to call stages that are supported by the Firestore backend but that
111111
* are not implemented in the SDK version being used.
112112
*
113-
* @param stage An [GenericStage] object that specifies stage name and parameters.
113+
* @param stage An [Stage] object that specifies stage name and parameters.
114114
* @return A new [Pipeline] object with this stage appended to the stage list.
115115
*/
116-
fun genericStage(stage: GenericStage): Pipeline = append(stage)
116+
fun addStage(stage: Stage): Pipeline = append(stage)
117117

118118
/**
119119
* Adds new fields to outputs from previous stages.

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.google.firebase.firestore.pipeline.FunctionExpr;
3838
import com.google.firebase.firestore.pipeline.InternalOptions;
3939
import com.google.firebase.firestore.pipeline.Ordering;
40-
import com.google.firebase.firestore.pipeline.Stage;
40+
import com.google.firebase.firestore.pipeline.BaseStage;
4141
import com.google.firestore.v1.Value;
4242
import java.util.ArrayList;
4343
import java.util.Collections;
@@ -600,7 +600,7 @@ private static BooleanExpr whereConditionsFromCursor(
600600
}
601601

602602
@NonNull
603-
private Stage<?> pipelineSource(FirebaseFirestore firestore) {
603+
private BaseStage<?> pipelineSource(FirebaseFirestore firestore) {
604604
if (isDocumentQuery()) {
605605
return new DocumentsSource(path.canonicalString());
606606
} else if (isCollectionGroupQuery()) {

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.google.firebase.firestore.util.Preconditions
2727
import com.google.firestore.v1.Pipeline
2828
import com.google.firestore.v1.Value
2929

30-
abstract class Stage<T : Stage<T>>
30+
abstract class BaseStage<T : BaseStage<T>>
3131
internal 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
100100
private 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 {
167167
internal class DatabaseSource
168168
@JvmOverloads
169169
internal 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

217217
class CollectionGroupSource
218218
private 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
246246
internal 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
257257
internal 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
349349
internal 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

478478
internal class LimitStage
479479
internal 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

486486
internal class OffsetStage
487487
internal 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
495495
internal 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
505505
internal 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
515515
internal 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
525525
internal 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
606606
internal 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
620620
internal 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

Comments
 (0)