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(Object document,
CodecRegistry codecRegistry)
A helper to convert an document of type Object to a BsonDocument
|
void |
clear() |
BsonDocument |
clone() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<String,BsonValue>> |
entrySet() |
boolean |
equals(Object o) |
BsonValue |
get(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.
|
Set<String> |
keySet() |
BsonValue |
put(String key,
BsonValue value) |
void |
putAll(Map<? extends String,? extends BsonValue> m) |
BsonValue |
remove(Object key) |
int |
size() |
String |
toString() |
Collection<BsonValue> |
values() |
append, get, getArray, getArray, getBinary, getBinary, getBoolean, getBoolean, getBsonType, getDateTime, getDateTime, getDecimal128, getDecimal128, getDocument, getDocument, getDouble, getDouble, 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
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static BsonDocument asBsonDocument(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()
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey
in interface Map<String,BsonValue>
containsKey
in class BsonDocument
public boolean containsValue(Object value)
containsValue
in interface Map<String,BsonValue>
containsValue
in class BsonDocument
public void clear()
public Collection<BsonValue> values()
public boolean equals(Object o)
public int hashCode()
public String toString()
toString
in class BsonDocument
public BsonDocument clone()
clone
in class BsonDocument