public class

BasicDBObjectBuilder

extends Object
java.lang.Object
   ↳ com.mongodb.BasicDBObjectBuilder

Class Overview

utility for building complex objects example: BasicDBObjectBuilder.start().add( "name" , "eliot" ).add( "number" , 17 ).get()

Summary

Public Constructors
BasicDBObjectBuilder()
creates an empty object
Public Methods
BasicDBObjectBuilder add(String key, Object val)
same as appends
BasicDBObjectBuilder append(String key, Object val)
appends the key/value to the active object
DBObject get()
gets the base object
boolean isEmpty()
returns true if no key/value was inserted into base object
BasicDBObjectBuilder pop()
pops the active object, which means that the parent object becomes active
BasicDBObjectBuilder push(String key)
creates an new empty object and inserts it into the current object with the given key.
static BasicDBObjectBuilder start()
Creates an empty object
static BasicDBObjectBuilder start(String k, Object val)
creates an object with the given key/value
static BasicDBObjectBuilder start(Map m)
Creates an object builder from an existing map.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BasicDBObjectBuilder ()

creates an empty object

Public Methods

public BasicDBObjectBuilder add (String key, Object val)

same as appends

Returns
  • returns itself so you can chain

public BasicDBObjectBuilder append (String key, Object val)

appends the key/value to the active object

Returns
  • returns itself so you can chain

public DBObject get ()

gets the base object

Returns
  • The base object

public boolean isEmpty ()

returns true if no key/value was inserted into base object

Returns
  • True if empty

public BasicDBObjectBuilder pop ()

pops the active object, which means that the parent object becomes active

Returns
  • returns itself so you can chain

public BasicDBObjectBuilder push (String key)

creates an new empty object and inserts it into the current object with the given key. The new child object becomes the active one.

Returns
  • returns itself so you can chain

public static BasicDBObjectBuilder start ()

Creates an empty object

Returns
  • The new empty builder

public static BasicDBObjectBuilder start (String k, Object val)

creates an object with the given key/value

Parameters
k The field name
val The value

public static BasicDBObjectBuilder start (Map m)

Creates an object builder from an existing map.

Parameters
m map to use
Returns
  • the new builder