public final class BsonUtils extends RuntimeException
| Modifier and Type | Field and Description |
|---|---|
static CodecRegistry |
DEFAULT_CODEC_REGISTRY
A basic codec registry which provides codecs for all BSON types, BSON documents, iterable
types, and maps.
|
| Constructor and Description |
|---|
BsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static BsonDocument |
copyOfDocument(BsonDocument document)
Returns a copy of the given document.
|
static <T> BsonDocument |
documentToBsonDocument(T document,
Codec<T> codec) |
static <T> BsonDocument |
documentToBsonDocument(T document,
CodecRegistry codecRegistry) |
static <T> Codec<T> |
getCodec(CodecRegistry codecRegistry,
Class<T> documentClass) |
static BsonValue |
getDocumentId(BsonDocument document) |
static <T> T |
parseValue(String json,
Class<T> valueClass)
Parses the provided extended JSON string and decodes it into a T value as specified by the
provided class type.
|
static <T> T |
parseValue(String json,
Class<T> valueClass,
CodecRegistry codecRegistry)
Parses the provided extended JSON string and decodes it into a T value as specified by the
provided class type.
|
static <T> T |
parseValue(String json,
Decoder<T> valueDecoder)
Parses the provided extended JSON string and decodes it into a T value as specified by the
provided
Decoder. |
static <T> BsonDocument |
toBsonDocument(Bson bson,
Class<T> documentClass,
CodecRegistry codecRegistry) |
static <T> BsonDocument |
toBsonDocumentOrNull(Bson document,
Class<T> documentClass,
CodecRegistry codecRegistry) |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic static final CodecRegistry DEFAULT_CODEC_REGISTRY
public static <T> T parseValue(String json, Decoder<T> valueDecoder)
Decoder.T - the type into which the JSON string is decoded.json - the JSON string to parse.valueDecoder - the Decoder to use to convert the BSON value into the type T.public static <T> T parseValue(String json, Class<T> valueClass)
CodecConfigurationException.T - the type into which the JSON string is decoded.json - the JSON string to parse.valueClass - the class that the JSON string should be decoded into.public static <T> T parseValue(String json, Class<T> valueClass, CodecRegistry codecRegistry)
CodecConfigurationException.T - the type into which the JSON string is decoded.json - the JSON string to parse.valueClass - the class that the JSON string should be decoded into.codecRegistry - the codec registry to use to find the codec for the provided class.public static <T> Codec<T> getCodec(CodecRegistry codecRegistry, Class<T> documentClass)
public static <T> BsonDocument documentToBsonDocument(T document, CodecRegistry codecRegistry)
public static <T> BsonDocument documentToBsonDocument(T document, Codec<T> codec)
public static <T> BsonDocument toBsonDocument(Bson bson, Class<T> documentClass, CodecRegistry codecRegistry)
public static BsonValue getDocumentId(BsonDocument document)
public static BsonDocument copyOfDocument(BsonDocument document)
document - the document to copy.public static <T> BsonDocument toBsonDocumentOrNull(Bson document, Class<T> documentClass, CodecRegistry codecRegistry)