public class BasicDBObjectBuilder extends Object
Utility for building complex objects. For example:
BasicDBObjectBuilder.start().add( "name" , "eliot").add("number" , 17).get()
Constructor | Description |
---|---|
BasicDBObjectBuilderβ() |
Creates a builder intialized with an empty document.
|
Modifier and Type | Method | Description |
---|---|---|
BasicDBObjectBuilder |
addβ(String key,
Object val) |
Same as append
|
BasicDBObjectBuilder |
appendβ(String key,
Object val) |
Appends the key/value to the active object
|
DBObject |
getβ() |
Gets the top level document.
|
boolean |
isEmptyβ() |
Returns true if no key/value was inserted into the top level document.
|
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 a builder intialized with an empty document.
|
static BasicDBObjectBuilder |
startβ(String key,
Object val) |
Creates a builder initialized with the given key/value.
|
static BasicDBObjectBuilder |
startβ(Map documentAsMap) |
Creates an object builder from an existing map of key value pairs.
|
public BasicDBObjectBuilderβ()
public static BasicDBObjectBuilder startβ()
public static BasicDBObjectBuilder startβ(String key, Object val)
key
- The field nameval
- The valuepublic static BasicDBObjectBuilder startβ(Map documentAsMap)
documentAsMap
- a document in Map form.public BasicDBObjectBuilder appendβ(String key, Object val)
key
- the field nameval
- the value of the fieldthis
so calls can be chainedpublic BasicDBObjectBuilder addβ(String key, Object val)
key
- the field nameval
- the value of the fieldthis
so calls can be chainedappend(String, Object)
public BasicDBObjectBuilder pushβ(String key)
key
- the field namethis
so calls can be chainedpublic BasicDBObjectBuilder popβ()
this
so calls can be chainedpublic DBObject getβ()
public boolean isEmptyβ()