Skip to content

Field

interface Field

A pair of a name and a value.

This type is used when iterating over the fields of a BsonDocument.

Equality & string representation

Different implementations of this interface are considered equal if:

  • Their name is equal.

  • Their value is equal (according to the equality rules of BsonValue).

The behavior of equals, hashCode and toString should be semantially equivalent to:

override fun equals(other: Any?): Boolean =
    other is BsonDocument.Field && name == other.name && value == other.value

override fun hashCode(): Int =
    name.hashCode() * 31 + value.hashCode()

override fun toString(): String =
    "($name, $value)"

Different implementations are allowed only as performance improvements, but the output must be identical to the implementations provided above.

Properties

name

abstract val name: String

value

abstract val value: BsonValue

Functions

component1

open operator fun component1(): String

component2

open operator fun component2(): BsonValue