T
- the type of the document that is wrappedpublic final class BsonDocumentWrapper<T> extends BsonDocument
BsonDocument
that begins its life as a document of any type and an Encoder
for that document, which lets an instance of
any class with an Encoder be treated as a BsonDocument. If any methods are called which required access to the individual elements of the
document, then, on demand, the document will be unwrapped into a BsonDocument using a BsonDocumentWriter
and the Encoder
.
But if all that is done with this document is to encode it, then the Encoder
will be used to do that.BsonDocumentWriter
,
Serialized FormConstructor and Description |
---|
BsonDocumentWrapper(T wrappedDocument,
Encoder<T> encoder)
Construct a new instance with the given document and encoder for the document.
|
Modifier and Type | Method and Description |
---|---|
static BsonDocument |
asBsonDocument(java.lang.Object document,
CodecRegistry codecRegistry)
A helper to convert an document of type Object to a BsonDocument
|
void |
clear() |
BsonDocument |
clone() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<java.lang.String,BsonValue>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
BsonValue |
get(java.lang.Object key) |
Encoder<T> |
getEncoder()
Get the encoder to use for the wrapped document.
|
T |
getWrappedDocument()
Get the wrapped document.
|
int |
hashCode() |
boolean |
isEmpty() |
boolean |
isUnwrapped()
Determine whether the document has been unwrapped already.
|
java.util.Set<java.lang.String> |
keySet() |
BsonValue |
put(java.lang.String key,
BsonValue value) |
void |
putAll(java.util.Map<? extends java.lang.String,? extends BsonValue> m) |
BsonValue |
remove(java.lang.Object key) |
int |
size() |
java.lang.String |
toString() |
java.util.Collection<BsonValue> |
values() |
append, get, getArray, getArray, getBinary, getBinary, getBoolean, getBoolean, getBsonType, getDateTime, getDateTime, getDecimal128, getDecimal128, getDocument, getDocument, getDouble, getDouble, getFirstKey, getInt32, getInt32, getInt64, getInt64, getNumber, getNumber, getObjectId, getObjectId, getRegularExpression, getRegularExpression, getString, getString, getTimestamp, getTimestamp, isArray, isBinary, isBoolean, isDateTime, isDecimal128, isDocument, isDouble, isInt32, isInt64, isNull, isNumber, isObjectId, isString, isTimestamp, parse, toBsonDocument, toJson, toJson
asArray, asBinary, asBoolean, asDateTime, asDBPointer, asDecimal128, asDocument, asDouble, asInt32, asInt64, asJavaScript, asJavaScriptWithScope, asNumber, asObjectId, asRegularExpression, asString, asSymbol, asTimestamp, isArray, isBinary, isBoolean, isDateTime, isDBPointer, isDecimal128, isDocument, isDouble, isInt32, isInt64, isJavaScript, isJavaScriptWithScope, isNull, isNumber, isObjectId, isRegularExpression, isString, isSymbol, isTimestamp
public static BsonDocument asBsonDocument(java.lang.Object document, CodecRegistry codecRegistry)
If not already a BsonDocument it looks up the documents' class in the codecRegistry and wraps it into a BsonDocumentWrapper
document
- the document to convertcodecRegistry
- the codecRegistry that can be used in the conversion of the Objectpublic T getWrappedDocument()
public Encoder<T> getEncoder()
public boolean isUnwrapped()
public int size()
size
in interface java.util.Map<java.lang.String,BsonValue>
size
in class BsonDocument
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,BsonValue>
isEmpty
in class BsonDocument
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,BsonValue>
containsKey
in class BsonDocument
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,BsonValue>
containsValue
in class BsonDocument
public BsonValue get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,BsonValue>
get
in class BsonDocument
public BsonValue put(java.lang.String key, BsonValue value)
put
in interface java.util.Map<java.lang.String,BsonValue>
put
in class BsonDocument
public BsonValue remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,BsonValue>
remove
in class BsonDocument
public void putAll(java.util.Map<? extends java.lang.String,? extends BsonValue> m)
putAll
in interface java.util.Map<java.lang.String,BsonValue>
putAll
in class BsonDocument
public void clear()
clear
in interface java.util.Map<java.lang.String,BsonValue>
clear
in class BsonDocument
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,BsonValue>
keySet
in class BsonDocument
public java.util.Collection<BsonValue> values()
values
in interface java.util.Map<java.lang.String,BsonValue>
values
in class BsonDocument
public java.util.Set<java.util.Map.Entry<java.lang.String,BsonValue>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,BsonValue>
entrySet
in class BsonDocument
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<java.lang.String,BsonValue>
equals
in class BsonDocument
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,BsonValue>
hashCode
in class BsonDocument
public java.lang.String toString()
toString
in class BsonDocument
public BsonDocument clone()
clone
in class BsonDocument