Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
feat(bson): Added byname for MutableBsonMapField
Browse files Browse the repository at this point in the history
  • Loading branch information
lsafer-meemer committed Jul 4, 2023
1 parent ec71648 commit 65a8320
Showing 1 changed file with 184 additions and 0 deletions.
184 changes: 184 additions & 0 deletions bson/src/main/kotlin/BsonDocument.kt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: BsonElement?) {
name by value
}

//

/**
Expand All @@ -150,6 +160,16 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: BsonDocument?) {
name by value
}

//

/**
Expand All @@ -173,6 +193,16 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: BsonArray?) {
name by value
}

/* ============= ------------------ ============= */

/**
Expand Down Expand Up @@ -200,6 +230,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonDocument].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Map<String, BsonElement>?) {
name by value
}

//

/**
Expand Down Expand Up @@ -227,6 +269,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonArray].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: List<BsonElement>?) {
name by value
}

//

/**
Expand Down Expand Up @@ -254,6 +308,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonString].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: String?) {
name by value
}

//

/**
Expand Down Expand Up @@ -281,6 +347,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonObjectId].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: ObjectId?) {
name by value
}

//

/**
Expand Down Expand Up @@ -309,6 +387,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped using [Id.bson].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: AnyId?) {
name by value
}

//

/**
Expand Down Expand Up @@ -340,6 +430,20 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped using [BsonArray] and [Id.bson].
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("byIdList")
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: List<AnyId>?) {
name by value
}

//

/**
Expand Down Expand Up @@ -367,6 +471,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonDecimal128].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Decimal128?) {
name by value
}

//

/**
Expand Down Expand Up @@ -394,6 +510,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonDecimal128].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: BigDecimal?) {
name by value
}

/* ============= ------------------ ============= */

/**
Expand Down Expand Up @@ -421,6 +549,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonBoolean].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Boolean?) {
name by value
}

//

/**
Expand Down Expand Up @@ -448,6 +588,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonInt32].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Int?) {
name by value
}

//

/**
Expand Down Expand Up @@ -475,6 +627,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonInt64].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Long?) {
name by value
}

//

/**
Expand Down Expand Up @@ -502,6 +666,18 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by value
}

/**
* Set the field with the name [this] to the given [value].
*
* If [value] is null then [BsonNull] will be set instead.
*
* The given [value] will be wrapped with [BsonDouble].
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(value: Double?) {
name by value
}

/* ============= ------------------ ============= */

/**
Expand All @@ -520,6 +696,14 @@ interface MutableBsonMap : BsonMap, MutableMap<String, BsonElement> {
name by block
}

/**
* Set the field with the name [this] to the value from invoking the given [block]
*/
@BsonConstructorMarker
infix fun MutableBsonMapField<*>.byname(block: BsonDocumentBlock) {
name by block
}

/* ============= ------------------ ============= */

/**
Expand Down

0 comments on commit 65a8320

Please sign in to comment.