public class BasicDBObjectBuilder
extends java.lang.Object
Utility for building complex objects. For example:
BasicDBObjectBuilder.start().add( "name" , "eliot").add("number" , 17).get()
Constructor and Description |
---|
BasicDBObjectBuilder()
Creates a builder intialized with an empty document.
|
Modifier and Type | Method and Description |
---|---|
BasicDBObjectBuilder |
add(java.lang.String key,
java.lang.Object val)
Same as append
|
BasicDBObjectBuilder |
append(java.lang.String key,
java.lang.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(java.lang.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(java.util.Map documentAsMap)
Creates an object builder from an existing map of key value pairs.
|
static BasicDBObjectBuilder |
start(java.lang.String key,
java.lang.Object val)
Creates a builder initialized with the given key/value.
|
public BasicDBObjectBuilder()
public static BasicDBObjectBuilder start()
public static BasicDBObjectBuilder start(java.lang.String key, java.lang.Object val)
key
- The field nameval
- The valuepublic static BasicDBObjectBuilder start(java.util.Map documentAsMap)
documentAsMap
- a document in Map form.public BasicDBObjectBuilder append(java.lang.String key, java.lang.Object val)
key
- the field nameval
- the value of the fieldthis
so calls can be chainedpublic BasicDBObjectBuilder add(java.lang.String key, java.lang.Object val)
key
- the field nameval
- the value of the fieldthis
so calls can be chainedappend(String, Object)
public BasicDBObjectBuilder push(java.lang.String key)
key
- the field namethis
so calls can be chainedpublic BasicDBObjectBuilder pop()
this
so calls can be chainedpublic DBObject get()
public boolean isEmpty()
Copyright © 2010 - 2020 Adobe. All Rights Reserved