object BSONWriter extends BSONWriterCompat
BSONWriter factories.
- Alphabetic
- By Inheritance
- BSONWriter
- BSONWriterCompat
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[T](write: (T) ⇒ BSONValue): BSONWriter[T]
Creates a BSONWriter based on the given
write
function.Creates a BSONWriter based on the given
write
function. This function is called within a scala.util.Try.import reactivemongo.api.bson.{ BSONWriter, BSONString } case class Foo(value: String) val foo: BSONWriter[Foo] = BSONWriter { f: Foo => BSONString(f.value) }
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
collect[T](write: PartialFunction[T, BSONValue]): BSONWriter[T]
Creates a BSONWriter based on the given partial function.
Creates a BSONWriter based on the given partial function.
A exceptions.ValueDoesNotMatchException is returned as
Failure
for any value that is not matched by thewrite
function.import reactivemongo.api.bson.{ BSONWriter, BSONInteger } val strCodeToIntWriter = BSONWriter.collect[String] { case "zero" => BSONInteger(0) case "one" => BSONInteger(1) } strCodeToIntWriter.writeTry("zero") // Success(BSONInteger(0)) strCodeToIntWriter.writeTry("one") // Success(BSONInteger(1)) strCodeToIntWriter.writeTry("3") // => Failure(ValueDoesNotMatchException(..)) strCodeToIntWriter.writeOpt("4") // None (as failed)
-
def
collectFrom[T](write: PartialFunction[T, Try[BSONValue]]): BSONWriter[T]
EXPERIMENTAL: Creates a BSONWriter based on the given partially safe
write
function.EXPERIMENTAL: Creates a BSONWriter based on the given partially safe
write
function.A exceptions.ValueDoesNotMatchException is returned as
Failure
for any value that is not matched by thewrite
function.import scala.util.Success import reactivemongo.api.bson.{ BSONWriter, BSONInteger } val strCodeToIntWriter = BSONWriter.collectFrom[String] { case "zero" => Success(BSONInteger(0)) case "one" => Success(BSONInteger(1)) } strCodeToIntWriter.writeTry("zero") // Success(BSONInteger(0)) strCodeToIntWriter.writeTry("one") // Success(BSONInteger(1)) strCodeToIntWriter.writeTry("3") // => Failure(IllegalArgumentException(..)) strCodeToIntWriter.writeOpt("4") // None (as failed)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from[T](write: (T) ⇒ Try[BSONValue]): BSONWriter[T]
Creates a BSONWriter based on the given safe
write
function.Creates a BSONWriter based on the given safe
write
function.import scala.util.{ Failure, Success } import reactivemongo.api.bson.{ BSONWriter, BSONInteger } val strCodeToIntWriter = BSONWriter.from[String] { case "zero" => Success(BSONInteger(0)) case "one" => Success(BSONInteger(1)) case _ => Failure(new IllegalArgumentException()) } strCodeToIntWriter.writeTry("zero") // Success(BSONInteger(0)) strCodeToIntWriter.writeTry("one") // Success(BSONInteger(1)) strCodeToIntWriter.writeTry("3") // => Failure(IllegalArgumentException(..)) strCodeToIntWriter.writeOpt("4") // None (as failed)
- write
the safe function to write
T
values as BSON
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
iterable[T, M[_]](write: (T) ⇒ Try[BSONValue])(implicit it: <:<[M[T], Iterable[T]]): BSONWriter[M[T]]
EXPERIMENTAL: (API may change without notice)
EXPERIMENTAL: (API may change without notice)
Creates a BSONWriter accepting only scala.collection.Iterable, and applying the given safe
write
function to each element value.import reactivemongo.api.bson.{ BSONWriter, Macros } case class Element(str: String, v: Int) val elementHandler = Macros.handler[Element] val setWriter: BSONWriter[Set[Element]] = BSONWriter.iterable[Element, Set](elementHandler writeTry _)
- Definition Classes
- BSONWriterCompat
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
option[T](write: (T) ⇒ Option[BSONValue]): BSONWriter[T]
Creates a BSONWriter based on the given
write
function.Creates a BSONWriter based on the given
write
function.import reactivemongo.api.bson.{ BSONWriter, BSONInteger } val strCodeToIntWriter = BSONWriter.option[String] { case "zero" => Some(BSONInteger(0)) case "one" => Some(BSONInteger(1)) case _ => None } strCodeToIntWriter.writeTry("zero") // Success(BSONInteger(0)) strCodeToIntWriter.writeTry("one") // Success(BSONInteger(1)) strCodeToIntWriter.writeTry("3") // => Failure(ValueDoesNotMatchException(..)) strCodeToIntWriter.writeOpt("4") // None (as failed)
-
def
sequence[T](write: (T) ⇒ Try[BSONValue]): BSONWriter[Seq[T]]
EXPERIMENTAL: (API may change without notice)
EXPERIMENTAL: (API may change without notice)
Creates a BSONWriter accepting only scala.collection.Iterable, and applying the given safe
write
function to each element value.import reactivemongo.api.bson.{ BSONWriter, Macros } case class Element(str: String, v: Int) val elementHandler = Macros.handler[Element] val seqWriter: BSONWriter[Seq[Element]] = BSONWriter.sequence[Element](elementHandler writeTry _)
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tuple2[A, B](implicit arg0: BSONWriter[A], arg1: BSONWriter[B]): BSONWriter[(A, B)]
EXPERIMENTAL: Creates a BSONWriter that creates tuple elements as BSONArray elements.
EXPERIMENTAL: Creates a BSONWriter that creates tuple elements as BSONArray elements.
import reactivemongo.api.bson.BSONWriter val writer = BSONWriter.tuple2[String, Int] writer.writeTry("Foo" -> 20) // => Success: ['Foo', 20]
-
def
tuple3[A, B, C](implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C]): BSONWriter[(A, B, C)]
EXPERIMENTAL: Creates a BSONWriter that creates tuple elements as BSONArray elements.
-
def
tuple4[A, B, C, D](implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C], arg3: BSONWriter[D]): BSONWriter[(A, B, C, D)]
EXPERIMENTAL: Creates a BSONWriter that creates tuple elements as BSONArray elements.
-
def
tuple5[A, B, C, D, E](implicit arg0: BSONWriter[A], arg1: BSONWriter[B], arg2: BSONWriter[C], arg3: BSONWriter[D], arg4: BSONWriter[E]): BSONWriter[(A, B, C, D, E)]
EXPERIMENTAL: Creates a BSONWriter that creates tuple elements as BSONArray elements.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()