82
82
*/
83
83
public final class Pipeline {
84
84
private final ImmutableList <Stage > stages ;
85
- private final String name ;
86
85
87
- private Pipeline (List <Stage > stages , String name ) {
86
+ private Pipeline (List <Stage > stages ) {
88
87
this .stages = ImmutableList .copyOf (stages );
89
- this .name = name ;
90
88
}
91
89
92
90
private Pipeline (Collection collection ) {
93
- this (Lists .newArrayList (collection ), collection . getPath () );
91
+ this (Lists .newArrayList (collection ));
94
92
}
95
93
96
94
private Pipeline (CollectionGroup group ) {
97
- this (Lists .newArrayList (group ), group . getCollectionId () );
95
+ this (Lists .newArrayList (group ));
98
96
}
99
97
100
98
private Pipeline (Database db ) {
101
- this (Lists .newArrayList (db ), db . getName () );
99
+ this (Lists .newArrayList (db ));
102
100
}
103
101
104
102
private Pipeline (Documents docs ) {
105
- this (Lists .newArrayList (docs ), docs .getName ());
106
- }
107
-
108
- public static Pipeline from (CollectionReference source ) {
109
- return new Pipeline (new Collection (source .getPath ()));
110
- }
111
-
112
- public static Pipeline from (com .google .cloud .firestore .CollectionGroup source ) {
113
- return new Pipeline (new CollectionGroup (source .options .getCollectionId ()));
103
+ this (Lists .newArrayList (docs ));
114
104
}
115
105
116
106
public static Pipeline fromCollection (String collectionName ) {
@@ -165,51 +155,46 @@ public Pipeline addFields(Selectable... fields) {
165
155
ImmutableList .<Stage >builder ()
166
156
.addAll (stages )
167
157
.add (new AddFields (projectablesToMap (fields )))
168
- .build (),
169
- name );
158
+ .build ());
170
159
}
171
160
172
161
public Pipeline select (Selectable ... projections ) {
173
162
return new Pipeline (
174
163
ImmutableList .<Stage >builder ()
175
164
.addAll (stages )
176
165
.add (new Select (projectablesToMap (projections )))
177
- .build (),
178
- name );
166
+ .build ());
179
167
}
180
168
181
169
public Pipeline select (String ... fields ) {
182
170
return new Pipeline (
183
171
ImmutableList .<Stage >builder ()
184
172
.addAll (stages )
185
173
.add (new Select (fieldNamesToMap (fields )))
186
- .build (),
187
- name );
174
+ .build ());
188
175
}
189
176
190
177
public Pipeline filter (FilterCondition condition ) {
191
178
return new Pipeline (
192
179
ImmutableList .<Stage >builder ()
193
180
.addAll (stages )
194
181
.add (new com .google .cloud .firestore .pipeline .stages .Filter (condition ))
195
- .build (),
196
- name );
182
+ .build ());
197
183
}
198
184
199
185
public Pipeline offset (int offset ) {
200
186
return new Pipeline (
201
- ImmutableList .<Stage >builder ().addAll (stages ).add (new Offset (offset )).build (), name );
187
+ ImmutableList .<Stage >builder ().addAll (stages ).add (new Offset (offset )).build ());
202
188
}
203
189
204
190
public Pipeline limit (int limit ) {
205
191
return new Pipeline (
206
- ImmutableList .<Stage >builder ().addAll (stages ).add (new Limit (limit )).build (), name );
192
+ ImmutableList .<Stage >builder ().addAll (stages ).add (new Limit (limit )).build ());
207
193
}
208
194
209
195
public Pipeline aggregate (AggregatorTarget ... aggregators ) {
210
196
return new Pipeline (
211
- ImmutableList .<Stage >builder ().addAll (stages ).add (new Aggregate (aggregators )).build (),
212
- name );
197
+ ImmutableList .<Stage >builder ().addAll (stages ).add (new Aggregate (aggregators )).build ());
213
198
}
214
199
215
200
public Pipeline findNearest (
@@ -226,17 +211,15 @@ public Pipeline findNearest(
226
211
.add (
227
212
new FindNearest (
228
213
property , vector , options )) // Assuming FindNearest takes these arguments
229
- .build (),
230
- name );
214
+ .build ());
231
215
}
232
216
233
217
public Pipeline sort (List <Ordering > orders , Sort .Density density , Sort .Truncation truncation ) {
234
218
return new Pipeline (
235
219
ImmutableList .<Stage >builder ()
236
220
.addAll (stages )
237
221
.add (new Sort (orders , density , truncation ))
238
- .build (),
239
- name );
222
+ .build ());
240
223
}
241
224
242
225
// Sugar
@@ -258,8 +241,7 @@ public Pipeline genericStage(String name, Map<String, Object> params) {
258
241
name ,
259
242
Lists .newArrayList (
260
243
params .values ()))) // Assuming GenericStage takes a list of params
261
- .build (),
262
- name );
244
+ .build ());
263
245
}
264
246
265
247
public ApiFuture <List <PipelineResult >> execute (Firestore db ) {
0 commit comments