KeyReader

object KeyReader
Companion:
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[T](read: String => T): KeyReader[T]

Creates a KeyReader based on the given read function.

Creates a KeyReader based on the given read function.

def collect[T](read: PartialFunction[String, T]): KeyReader[T]

Creates a KeyReader based on the given partial function.

Creates a KeyReader based on the given partial function.

A exceptions.ValueDoesNotMatchException is returned as Failure for any BSON value that is not matched by the read function.

def from[T](readTry: String => Try[T]): KeyReader[T]

Creates a KeyReader based on the given readTry function.

Creates a KeyReader based on the given readTry function.

def option[T](read: String => Option[T]): KeyReader[T]

Creates a KeyReader based on the given read function.

Creates a KeyReader based on the given read function.

Implicits

Implicits

implicit def intKeyReader: KeyReader[Int]
implicit def keyReader[T](implicit conv: String => T): KeyReader[T]

Provides a KeyReader instance of any T type that can be parsed from a String.

Provides a KeyReader instance of any T type that can be parsed from a String.

implicit lazy val localeReader: KeyReader[Locale]

Supports reading locales as keys, using language tag as string representation.

Supports reading locales as keys, using language tag as string representation.

import reactivemongo.api.bson.KeyReader

implicitly[KeyReader[java.util.Locale]].readTry("fr-FR")
// => Success(Locale.FRANCE)
implicit lazy val uuidReader: KeyReader[UUID]

Supports reading UUID as keys.

Supports reading UUID as keys.

import reactivemongo.api.bson.KeyReader

implicitly[KeyReader[java.util.UUID]].
 readTry("BDE87A8B-52F6-4345-9BCE-A30F4CB9FCB4")
// => Success(java.util.UUID{"BDE87A8B-52F6-4345-9BCE-A30F4CB9FCB4"})