Skip to content

Commit 33d20b5

Browse files
author
Roman Janusz
committed
trailing commas
1 parent 9b097cd commit 33d20b5

File tree

4 files changed

+53
-53
lines changed

4 files changed

+53
-53
lines changed

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedClientSession.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TypedClientSession(val nativeSession: ClientSession)
2323
nativeSession.getTransactionOptions
2424

2525
def startTransaction(
26-
transactionOptions: TransactionOptions = TransactionOptions.builder().build()
26+
transactionOptions: TransactionOptions = TransactionOptions.builder().build(),
2727
): Unit =
2828
nativeSession.startTransaction(transactionOptions)
2929

@@ -39,9 +39,9 @@ class TypedClientSession(val nativeSession: ClientSession)
3939
* error is propagated. The transaction is also aborted upon cancellation.
4040
*/
4141
def inTransaction[T](
42-
transactionOptions: TransactionOptions = TransactionOptions.builder().build()
42+
transactionOptions: TransactionOptions = TransactionOptions.builder().build(),
4343
)(
44-
task: Task[T]
44+
task: Task[T],
4545
): Task[T] = Task.defer {
4646
startTransaction(transactionOptions)
4747
task.guaranteeCase {

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedMongoClient.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object TypedMongoClient {
4444
*/
4545
class TypedMongoClient(
4646
val nativeClient: MongoClient,
47-
val clientSession: OptArg[TypedClientSession] = OptArg.Empty
47+
val clientSession: OptArg[TypedClientSession] = OptArg.Empty,
4848
) extends TypedMongoUtils with Closeable {
4949
private val sessionOrNull = clientSession.toOpt.map(_.nativeSession).orNull
5050

@@ -66,7 +66,7 @@ class TypedMongoClient(
6666
//TODO: `watch` methods
6767

6868
def startSession(
69-
options: ClientSessionOptions = ClientSessionOptions.builder().build()
69+
options: ClientSessionOptions = ClientSessionOptions.builder().build(),
7070
): Task[TypedClientSession] =
7171
single(nativeClient.startSession(options)).map(new TypedClientSession(_))
7272

@@ -78,9 +78,9 @@ class TypedMongoClient(
7878
* returned copy of these objects.
7979
*/
8080
def inSession[T](
81-
options: ClientSessionOptions = ClientSessionOptions.builder().build()
81+
options: ClientSessionOptions = ClientSessionOptions.builder().build(),
8282
)(
83-
task: TypedClientSession => Task[T]
83+
task: TypedClientSession => Task[T],
8484
): Task[T] =
8585
startSession(options).bracket(task)(s => Task(s.close()))
8686

@@ -97,7 +97,7 @@ class TypedMongoClient(
9797
sessionOptions: ClientSessionOptions = ClientSessionOptions.builder().build(),
9898
transactionOptions: TransactionOptions = TransactionOptions.builder().build(),
9999
)(
100-
task: TypedClientSession => Task[T]
100+
task: TypedClientSession => Task[T],
101101
): Task[T] =
102102
inSession(sessionOptions)(s => s.inTransaction(transactionOptions)(task(s)))
103103

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedMongoCollection.scala

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
2020
docCollection: MongoCollection[BsonDocument],
2121
val clientSession: Opt[TypedClientSession],
2222
)(implicit
23-
meta: MongoEntityMeta[E]
23+
meta: MongoEntityMeta[E],
2424
) extends DataTypeDsl[E] with TypedMongoUtils {
2525

2626
def this(
2727
rawCollection: MongoCollection[_],
28-
clientSession: OptArg[TypedClientSession] = OptArg.Empty
28+
clientSession: OptArg[TypedClientSession] = OptArg.Empty,
2929
)(implicit
30-
meta: MongoEntityMeta[E]
30+
meta: MongoEntityMeta[E],
3131
) = this(
3232
TypedMongoCollection.mkNativeCollection[E](rawCollection),
3333
rawCollection.withDocumentClass(classOf[BsonDocument]),
34-
clientSession.toOpt
34+
clientSession.toOpt,
3535
)
3636

3737
type ID = E#IDType
@@ -98,51 +98,51 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
9898

9999
def renameCollection(
100100
namespace: MongoNamespace,
101-
setupOptions: RenameCollectionOptions => RenameCollectionOptions = identity
101+
setupOptions: RenameCollectionOptions => RenameCollectionOptions = identity,
102102
): Task[Unit] =
103103
empty(optionalizeFirstArg(
104-
nativeCollection.renameCollection(sessionOrNull, namespace, setupOptions(new RenameCollectionOptions))
104+
nativeCollection.renameCollection(sessionOrNull, namespace, setupOptions(new RenameCollectionOptions)),
105105
))
106106

107107
def countDocuments(
108108
filter: MongoDocumentFilter[E] = MongoFilter.empty,
109-
setupOptions: CountOptions => CountOptions = identity
109+
setupOptions: CountOptions => CountOptions = identity,
110110
): Task[Long] =
111111
single(optionalizeFirstArg(
112-
nativeCollection.countDocuments(sessionOrNull, filter.toBson, setupOptions(new CountOptions))
112+
nativeCollection.countDocuments(sessionOrNull, filter.toBson, setupOptions(new CountOptions)),
113113
)).asInstanceOf[Task[Long]]
114114

115115
def estimatedDocumentCount(
116-
setupOptions: EstimatedDocumentCountOptions => EstimatedDocumentCountOptions = identity
116+
setupOptions: EstimatedDocumentCountOptions => EstimatedDocumentCountOptions = identity,
117117
): Task[Long] =
118118
single(nativeCollection.estimatedDocumentCount(setupOptions(new EstimatedDocumentCountOptions)))
119119
.asInstanceOf[Task[Long]]
120120

121121
def exists(
122122
filter: MongoDocumentFilter[E],
123-
setupOptions: CountOptions => CountOptions = identity
123+
setupOptions: CountOptions => CountOptions = identity,
124124
): Task[Boolean] =
125125
countDocuments(filter, options => setupOptions(options).limit(1)).map(_ > 0)
126126

127127
def findById(
128128
id: ID,
129-
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity
129+
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity,
130130
): Task[Option[E]] =
131131
findOne(IdRef === id, setupOptions = setupOptions)
132132

133133
def findOne[T](
134134
filter: MongoDocumentFilter[E] = MongoFilter.empty,
135135
projection: MongoProjection[E, T] = SelfRef,
136136
sort: MongoDocumentOrder[E] = MongoDocumentOrder.unspecified,
137-
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity
137+
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity,
138138
): Task[Option[T]] =
139139
find(filter, projection, sort, o => setupOptions(o).limit(1)).firstOptionL
140140

141141
def find[T](
142142
filter: MongoDocumentFilter[E] = MongoFilter.empty,
143143
projection: MongoProjection[E, T] = SelfRef,
144144
sort: MongoDocumentOrder[E] = MongoDocumentOrder.unspecified,
145-
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity
145+
setupOptions: FindPublisher[Any] => FindPublisher[Any] = identity,
146146
): Observable[T] = {
147147

148148
def setupPublisher[T0](publisher: FindPublisher[T0]): FindPublisher[T0] = {
@@ -171,7 +171,7 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
171171
projection: MongoProjection[E, T] = SelfRef,
172172
sort: MongoDocumentOrder[E] = MongoDocumentOrder.unspecified,
173173
upsert: Boolean = false, // extracted as separate param because it's very commonly used
174-
setupOptions: FindOneAndUpdateOptions => FindOneAndUpdateOptions = identity
174+
setupOptions: FindOneAndUpdateOptions => FindOneAndUpdateOptions = identity,
175175
): Task[Option[T]] = {
176176
val filterBson = filter.toFilterBson(Opt.Empty, projection.projectionRefs)
177177
val options = setupOptions(new FindOneAndUpdateOptions).sort(sort.toBson).upsert(upsert)
@@ -182,12 +182,12 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
182182
projection match {
183183
case SelfRef =>
184184
singleOpt(optionalizeFirstArg(
185-
nativeCollection.findOneAndUpdate(sessionOrNull, filterBson, updateBson, options)
185+
nativeCollection.findOneAndUpdate(sessionOrNull, filterBson, updateBson, options),
186186
).asInstanceOf[Publisher[T]])
187187
case proj =>
188188
val optionsWithProj = options.projection(proj.toProjectionBson)
189189
singleOpt(optionalizeFirstArg(
190-
docCollection.findOneAndUpdate(sessionOrNull, filterBson, updateBson, optionsWithProj)
190+
docCollection.findOneAndUpdate(sessionOrNull, filterBson, updateBson, optionsWithProj),
191191
)).map(_.map(proj.decodeFrom))
192192
}
193193
}
@@ -198,20 +198,20 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
198198
projection: MongoProjection[E, T] = SelfRef,
199199
sort: MongoDocumentOrder[E] = MongoDocumentOrder.unspecified,
200200
upsert: Boolean = false, // extracted as separate param because it's very commonly used
201-
setupOptions: FindOneAndReplaceOptions => FindOneAndReplaceOptions = identity
201+
setupOptions: FindOneAndReplaceOptions => FindOneAndReplaceOptions = identity,
202202
): Task[Option[T]] = {
203203
val filterBson = filter.toFilterBson(Opt.Empty, projection.projectionRefs)
204204
val options = setupOptions(new FindOneAndReplaceOptions).sort(sort.toBson).upsert(upsert)
205205
projection match {
206206
case SelfRef =>
207207
singleOpt(optionalizeFirstArg(
208-
nativeCollection.findOneAndReplace(sessionOrNull, filterBson, replacement, options)
208+
nativeCollection.findOneAndReplace(sessionOrNull, filterBson, replacement, options),
209209
).asInstanceOf[Publisher[T]])
210210
case proj =>
211211
val replaceDoc = format.writeBson(replacement).asDocument
212212
val optionsWithProj = options.projection(proj.toProjectionBson)
213213
singleOpt(optionalizeFirstArg(
214-
docCollection.findOneAndReplace(sessionOrNull, filterBson, replaceDoc, optionsWithProj)
214+
docCollection.findOneAndReplace(sessionOrNull, filterBson, replaceDoc, optionsWithProj),
215215
)).map(_.map(proj.decodeFrom))
216216
}
217217
}
@@ -220,27 +220,27 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
220220
filter: MongoDocumentFilter[E],
221221
projection: MongoProjection[E, T] = SelfRef,
222222
sort: MongoDocumentOrder[E] = MongoDocumentOrder.unspecified,
223-
setupOptions: FindOneAndDeleteOptions => FindOneAndDeleteOptions = identity
223+
setupOptions: FindOneAndDeleteOptions => FindOneAndDeleteOptions = identity,
224224
): Task[Option[T]] = {
225225
val filterBson = filter.toFilterBson(Opt.Empty, projection.projectionRefs)
226226
val options = setupOptions(new FindOneAndDeleteOptions).sort(sort.toBson)
227227
projection match {
228228
case SelfRef =>
229229
singleOpt(optionalizeFirstArg(
230-
nativeCollection.findOneAndDelete(sessionOrNull, filterBson, options)
230+
nativeCollection.findOneAndDelete(sessionOrNull, filterBson, options),
231231
).asInstanceOf[Publisher[T]])
232232
case proj =>
233233
val optionsWithProj = options.projection(proj.toProjectionBson)
234234
singleOpt(optionalizeFirstArg(
235-
docCollection.findOneAndDelete(sessionOrNull, filterBson, optionsWithProj))
235+
docCollection.findOneAndDelete(sessionOrNull, filterBson, optionsWithProj)),
236236
).map(_.map(proj.decodeFrom))
237237
}
238238
}
239239

240240
def distinct[T](
241241
property: MongoPropertyRef[E, T],
242242
filter: MongoDocumentFilter[E] = MongoFilter.empty,
243-
setupOptions: DistinctPublisher[Any] => DistinctPublisher[Any] = identity
243+
setupOptions: DistinctPublisher[Any] => DistinctPublisher[Any] = identity,
244244
): Observable[T] = {
245245

246246
val publisher =
@@ -255,104 +255,104 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
255255

256256
def insertOne(
257257
value: E,
258-
setupOptions: InsertOneOptions => InsertOneOptions = identity
258+
setupOptions: InsertOneOptions => InsertOneOptions = identity,
259259
): Task[InsertOneResult] =
260260
single(optionalizeFirstArg(
261-
nativeCollection.insertOne(sessionOrNull, value, setupOptions(new InsertOneOptions))
261+
nativeCollection.insertOne(sessionOrNull, value, setupOptions(new InsertOneOptions)),
262262
))
263263

264264
def insertMany(
265265
values: Seq[E],
266-
setupOptions: InsertManyOptions => InsertManyOptions = identity
266+
setupOptions: InsertManyOptions => InsertManyOptions = identity,
267267
): Task[InsertManyResult] =
268268
single(optionalizeFirstArg(
269-
nativeCollection.insertMany(sessionOrNull, values.asJava, setupOptions(new InsertManyOptions))
269+
nativeCollection.insertMany(sessionOrNull, values.asJava, setupOptions(new InsertManyOptions)),
270270
))
271271

272272
def deleteOne(
273273
filter: MongoDocumentFilter[E],
274-
setupOptions: DeleteOptions => DeleteOptions = identity
274+
setupOptions: DeleteOptions => DeleteOptions = identity,
275275
): Task[DeleteResult] =
276276
single(optionalizeFirstArg(
277-
nativeCollection.deleteOne(sessionOrNull, filter.toBson, setupOptions(new DeleteOptions))
277+
nativeCollection.deleteOne(sessionOrNull, filter.toBson, setupOptions(new DeleteOptions)),
278278
))
279279

280280
def deleteMany(
281281
filter: MongoDocumentFilter[E],
282-
setupOptions: DeleteOptions => DeleteOptions = identity
282+
setupOptions: DeleteOptions => DeleteOptions = identity,
283283
): Task[DeleteResult] =
284284
single(optionalizeFirstArg(
285-
nativeCollection.deleteMany(sessionOrNull, filter.toBson, setupOptions(new DeleteOptions))
285+
nativeCollection.deleteMany(sessionOrNull, filter.toBson, setupOptions(new DeleteOptions)),
286286
))
287287

288288
def updateOne(
289289
filter: MongoDocumentFilter[E],
290290
update: MongoDocumentUpdate[E],
291291
upsert: Boolean = false, // extracted as separate param because it's very commonly used
292-
setupOptions: UpdateOptions => UpdateOptions = identity
292+
setupOptions: UpdateOptions => UpdateOptions = identity,
293293
): Task[UpdateResult] = {
294294
val options = setupOptions(new UpdateOptions).upsert(upsert)
295295
val (updateBson, arrayFilters) = update.toBsonAndArrayFilters
296296
if (!arrayFilters.isEmpty) {
297297
options.arrayFilters(arrayFilters)
298298
}
299299
single(optionalizeFirstArg(
300-
nativeCollection.updateOne(sessionOrNull, filter.toBson, updateBson, options)
300+
nativeCollection.updateOne(sessionOrNull, filter.toBson, updateBson, options),
301301
))
302302
}
303303

304304
def updateMany(
305305
filter: MongoDocumentFilter[E],
306306
update: MongoDocumentUpdate[E],
307307
upsert: Boolean = false, // extracted as separate param because it's very commonly used
308-
setupOptions: UpdateOptions => UpdateOptions = identity
308+
setupOptions: UpdateOptions => UpdateOptions = identity,
309309
): Task[UpdateResult] = {
310310
val options = setupOptions(new UpdateOptions).upsert(upsert)
311311
val (updateBson, arrayFilters) = update.toBsonAndArrayFilters
312312
if (!arrayFilters.isEmpty) {
313313
options.arrayFilters(arrayFilters)
314314
}
315315
single(optionalizeFirstArg(
316-
nativeCollection.updateMany(sessionOrNull, filter.toBson, updateBson, options)
316+
nativeCollection.updateMany(sessionOrNull, filter.toBson, updateBson, options),
317317
))
318318
}
319319

320320
def replaceOne(
321321
filter: MongoDocumentFilter[E],
322322
replacement: E,
323323
upsert: Boolean = false, // extracted as separate param because it's very commonly used
324-
setupOptions: ReplaceOptions => ReplaceOptions = identity
324+
setupOptions: ReplaceOptions => ReplaceOptions = identity,
325325
): Task[UpdateResult] = {
326326
val options = setupOptions(new ReplaceOptions).upsert(upsert)
327327
single(optionalizeFirstArg(
328-
nativeCollection.replaceOne(sessionOrNull, filter.toBson, replacement, options)
328+
nativeCollection.replaceOne(sessionOrNull, filter.toBson, replacement, options),
329329
))
330330
}
331331

332332
def bulkWrite(
333333
writes: Seq[MongoWrite[E]],
334-
setupOptions: BulkWriteOptions => BulkWriteOptions = identity
334+
setupOptions: BulkWriteOptions => BulkWriteOptions = identity,
335335
): Task[BulkWriteResult] = {
336336
val requests = writes.iterator.map(_.toWriteModel).to(JList)
337337
single(optionalizeFirstArg(
338-
nativeCollection.bulkWrite(sessionOrNull, requests, setupOptions(new BulkWriteOptions))
338+
nativeCollection.bulkWrite(sessionOrNull, requests, setupOptions(new BulkWriteOptions)),
339339
))
340340
}
341341

342342
def createIndex(index: MongoIndex[E]): Task[String] =
343343
single(optionalizeFirstArg(
344-
nativeCollection.createIndex(sessionOrNull, index.toBson, index.setupOptions(new IndexOptions))
344+
nativeCollection.createIndex(sessionOrNull, index.toBson, index.setupOptions(new IndexOptions)),
345345
))
346346

347347
def createIndexes(
348348
indexes: Seq[MongoIndex[E]],
349-
setupOptions: CreateIndexOptions => CreateIndexOptions = identity
349+
setupOptions: CreateIndexOptions => CreateIndexOptions = identity,
350350
): Task[String] = {
351351
val indexModels = indexes.iterator
352352
.map(index => new IndexModel(index.toBson, index.setupOptions(new IndexOptions)))
353353
.to(JList)
354354
single(optionalizeFirstArg(
355-
nativeCollection.createIndexes(sessionOrNull, indexModels, setupOptions(new CreateIndexOptions))
355+
nativeCollection.createIndexes(sessionOrNull, indexModels, setupOptions(new CreateIndexOptions)),
356356
))
357357
}
358358

@@ -365,9 +365,9 @@ class TypedMongoCollection[E <: BaseMongoEntity] private(
365365

366366
object TypedMongoCollection {
367367
private def mkNativeCollection[E <: BaseMongoEntity : MongoEntityMeta](
368-
rawCollection: MongoCollection[_]
368+
rawCollection: MongoCollection[_],
369369
)(implicit
370-
meta: MongoEntityMeta[E]
370+
meta: MongoEntityMeta[E],
371371
): MongoCollection[E] = {
372372
import meta.format._
373373
val codecRegistry: CodecRegistry = GenCodecRegistry.create[E](rawCollection.getCodecRegistry)

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedMongoDatabase.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TypedMongoDatabase(
5858
setupOptions: CreateCollectionOptions => CreateCollectionOptions = identity,
5959
): Task[Unit] =
6060
empty(optionalizeFirstArg(
61-
nativeDatabase.createCollection(sessionOrNull, name, setupOptions(new CreateCollectionOptions))
61+
nativeDatabase.createCollection(sessionOrNull, name, setupOptions(new CreateCollectionOptions)),
6262
))
6363

6464
//TODO: `createView`, `watch`, `aggregate`

0 commit comments

Comments
 (0)