public class BsonUtils extends Object
| Constructor and Description |
|---|
BsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addToMap(org.bson.conversions.Bson bson,
String key,
Object value) |
static Map<String,Object> |
asMap(org.bson.conversions.Bson bson) |
static <T> T |
get(org.bson.conversions.Bson bson,
String key) |
static boolean |
isJsonArray(String value)
Check if a given String looks like
parsable json array. |
static boolean |
isJsonDocument(String value)
Check if a given String looks like
parsable json. |
static org.bson.Document |
merge(org.bson.Document... documents)
Merge the given
documents into on in the given order. |
static org.bson.Document |
parse(String json,
CodecRegistryProvider codecRegistryProvider)
Parse the given json to
Document applying transformations as specified by a potentially given
Codec. |
static org.bson.BsonValue |
simpleToBsonValue(Object source)
Convert a given simple value (eg.
|
static org.bson.Document |
toDocumentOrElse(String source,
Function<String,org.bson.Document> orElse) |
static Object |
toJavaType(org.bson.BsonValue value)
Extract the corresponding plain value from
BsonValue. |
static String |
toJson(org.bson.Document source)
Serialize the given
Document as Json applying default codecs if necessary. |
public static void addToMap(org.bson.conversions.Bson bson,
String key,
@Nullable
Object value)
public static Object toJavaType(org.bson.BsonValue value)
value - must not be null.public static org.bson.BsonValue simpleToBsonValue(Object source)
source - must not be null.BsonValue representation.IllegalArgumentException - if source does not correspond to a BsonValue type.public static org.bson.Document merge(org.bson.Document... documents)
documents into on in the given order. Keys contained within multiple documents are
overwritten by their follow ups.documents - must not be null. Can be empty.public static org.bson.Document toDocumentOrElse(String source, Function<String,org.bson.Document> orElse)
source - orElse - @Nullable public static String toJson(@Nullable org.bson.Document source)
Document as Json applying default codecs if necessary.source - public static boolean isJsonDocument(@Nullable String value)
parsable json.value - can be null.public static boolean isJsonArray(@Nullable String value)
parsable json array.value - can be null.public static org.bson.Document parse(String json, @Nullable CodecRegistryProvider codecRegistryProvider)
Document applying transformations as specified by a potentially given
Codec.json - must not be null.codecRegistryProvider - can be null. In that case the default DocumentCodec is used.IllegalArgumentException - if the required argument is null.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.