クラス BsonUtils

java.lang.ObjectSE
org.springframework.data.mongodb.util.BsonUtils

public class BsonUtils extends ObjectSE
Document または DBObject のいずれかである Bson 要素に対する操作のための内部 API。
導入:
2.0
作成者:
Christoph Strobl, Mark Paluch
  • フィールドの詳細

    • EMPTY_DOCUMENT

      public static final Document EMPTY_DOCUMENT
      空のドキュメント (不変)。このドキュメントは直列化可能です。
      導入:
      3.2.5
  • コンストラクターの詳細

    • BsonUtils

      public BsonUtils()
  • 方法の詳細

    • get

      @Contract("null, _ -> null") public static <T> @Nullable T get(@Nullable Bson bson, StringSE key)
    • asMap

      public static MapSE<StringSE,ObjectSE> asMap(@Nullable Bson bson)
      Return the Bson object as MapSE . Depending on the input type, the return value can be either a casted version of bson or a converted (detached from the original value).
      パラメーター:
      bson -
      戻り値:
    • asMap

      public static MapSE<StringSE,ObjectSE> asMap(@Nullable Bson bson, CodecRegistry codecRegistry)
      Return the Bson object as MapSE . Depending on the input type, the return value can be either a casted version of bson or a converted (detached from the original value) using the given CodecRegistry to obtain codecs that might be required for conversion.
      パラメーター:
      bson - null でもかまいません。
      codecRegistry - null であってはなりません。
      戻り値:
      never null. Returns an empty MapSE if input Bson is null.
      導入:
      4.0
    • asDocument

      public static Document asDocument(@Nullable Bson bson)
      Return the Bson object as Document . Depending on the input type, the return value can be either a casted version of bson or a converted (detached from the original value).
      パラメーター:
      bson -
      戻り値:
      導入:
      3.2.5
    • asDocument

      public static Document asDocument(@Nullable Bson bson, CodecRegistry codecRegistry)
      Return the Bson object as Document . Depending on the input type, the return value can be either a casted version of bson or a converted (detached from the original value) using the given CodecRegistry to obtain codecs that might be required for conversion.
      パラメーター:
      bson -
      codecRegistry - null であってはなりません。
      戻り値:
      決して null にはなりません。
      導入:
      4.0
    • asMutableDocument

      public static Document asMutableDocument(Bson bson)
      Return the Bson object as mutable Document containing all entries from Bson
      パラメーター:
      bson -
      戻り値:
      a mutable Document containing all entries from Bson
      導入:
      3.2.5
    • addToMap

      public static void addToMap(Bson bson, StringSE key, @Nullable ObjectSE value)
    • addAllToMap

      public static void addAllToMap(Bson target, MapSE<StringSE,?> source)
      指定されたソース MapSE からのすべてのエントリをターゲットに追加します。
      パラメーター:
      target - null であってはなりません。
      source - null であってはなりません。
      導入:
      3.2
    • contains

      public static boolean contains(Bson bson, StringSE key, @Nullable ObjectSE value)
      Check if a given entry (key/value pair) is present in the given Bson
      パラメーター:
      bson - null であってはなりません。
      key - null であってはなりません。
      value - null でもかまいません。
      戻り値:
      (キー / 値のペア) が存在する場合は true。
      導入:
      3.2
    • removeNullId

      public static boolean removeNullId(Bson bson)
      Remove _id : null from the given Bson if present.
      パラメーター:
      bson - null であってはなりません。
      導入:
      3.2
    • toJavaType

      public static ObjectSE toJavaType(BsonValue value)
      Extract the corresponding plain value from BsonValue . Eg. plain StringSE from BsonString
      パラメーター:
      value - null であってはなりません。
      戻り値:
      導入:
      2.1
    • simpleToBsonValue

      public static BsonValue simpleToBsonValue(@Nullable ObjectSE source)
      Convert a given simple value (eg.StringSE, LongSE ) to its corresponding BsonValue
      パラメーター:
      source - null であってはなりません。
      戻り値:
      the corresponding BsonValue representation.
      例外:
      IllegalArgumentExceptionSE - if source does not correspond to a BsonValue type.
      導入:
      3.0
    • simpleToBsonValue

      @Contract("null, _ -> !null") public static BsonValue simpleToBsonValue(@Nullable ObjectSE source, CodecRegistry codecRegistry)
      Convert a given simple value (eg.StringSE, LongSE ) to its corresponding BsonValue
      パラメーター:
      source - null でもかまいません。
      codecRegistry - The CodecRegistry used as a fallback to convert types using native Codec . Must not be null.
      戻り値:
      the corresponding BsonValue representation.
      例外:
      IllegalArgumentExceptionSE - if source does not correspond to a BsonValue type.
      導入:
      4.2
    • merge

      public static Document merge(Document... documents)
      Merge the given documents into on in the given order. Keys contained within multiple documents are overwritten by their follow-ups.
      パラメーター:
      documents - null であってはなりません。空であっても構いません。
      戻り値:
      すべてのキーと値のペアを含むドキュメント。
      導入:
      2.2
    • toDocumentOrElse

      public static Document toDocumentOrElse(StringSE source, FunctionSE<StringSE,Document> orElse)
      パラメーター:
      source -
      orElse -
      戻り値:
      導入:
      2.2
    • toJson

      public static @Nullable StringSE toJson(@Nullable Document source)
      Serialize the given Document as Json applying default codecs if necessary.
      パラメーター:
      source -
      戻り値:
      導入:
      2.2.1
    • isJsonDocument

      @Contract("null -> false") public static boolean isJsonDocument(@Nullable StringSE value)
      Check if a given String looks like parsable json.
      パラメーター:
      value - null でもかまいません。
      戻り値:
      指定された値が JSON ドキュメントのように見える場合は true。
      導入:
      3.0
    • isJsonArray

      @Contract("null -> false") public static boolean isJsonArray(@Nullable StringSE value)
      Check if a given String looks like parsable json array.
      パラメーター:
      value - null でもかまいません。
      戻り値:
      指定された値が json 配列のように見える場合は true です。
      導入:
      3.0
    • parse

      public static Document parse(StringSE json, @Nullable CodecRegistryProvider codecRegistryProvider)
      指定された JSON を、指定された Codec で指定される変換を適用して Document に解析します。
      パラメーター:
      json - null であってはなりません。
      codecRegistryProvider - can be null. In that case the default DocumentCodec is used.
      戻り値:
      決して null にはなりません。
      例外:
      IllegalArgumentExceptionSE - 必要な引数が null の場合。
      導入:
      3.0
    • resolveValue

      public static @Nullable ObjectSE resolveValue(Bson bson, StringSE key)
      指定されたキーの値を解決します。指定された Bson 値にキーが含まれている場合は、その値がすぐに返されます。キーにドット (.) 表記を使用したパスが含まれている場合は、個々の部分をインスペクションしてパスを解決しようとします。中間の 1 つが null であるか、それ以上インスペクションできない (間違った) 型の場合は、null が返されます。
      パラメーター:
      bson - インスペクションするソース。null にすることはできません。
      key - 検索するキー。null にすることはできません。
      戻り値:
      null でもかまいません。
      導入:
      3.0.8
    • resolveValue

      public static @Nullable ObjectSE resolveValue(Bson bson, FieldName fieldName)
      Resolve the value for a given field name . If the given name is a FieldName.Type.KEY the value is obtained from the target Bson immediately. If the given fieldName is a FieldName.Type.PATH maybe using the dot (.) notation it will try to resolve the path by inspecting the individual parts. If one of the intermediate ones is null or cannot be inspected further (wrong) type, null is returned.
      パラメーター:
      bson - インスペクションするソース。null にすることはできません。
      fieldName - 検索する名前。null にすることはできません。
      戻り値:
      null でもかまいません。
      導入:
      4.2
    • resolveValue

      public static @Nullable ObjectSE resolveValue(MapSE<StringSE,ObjectSE> source, FieldName fieldName)
      Resolve the value for a given field name . If the given name is a FieldName.Type.KEY the value is obtained from the target Bson immediately. If the given fieldName is a FieldName.Type.PATH maybe using the dot (.) notation it will try to resolve the path by inspecting the individual parts. If one of the intermediate ones is null or cannot be inspected further (wrong) type, null is returned.
      パラメーター:
      source - インスペクションするソース。null にすることはできません。
      fieldName - 検索するキー。null にすることはできません。
      戻り値:
      null でもかまいません。
      導入:
      4.2
    • resolveValue

      public static @Nullable ObjectSE resolveValue(MapSE<StringSE,ObjectSE> source, StringSE key)
      指定されたキーの値を解決します。指定された MapSE 値にキーが含まれている場合は、その値がすぐに返されます。キーにドット (.) 表記を使用したパスが含まれている場合は、個々の部分をインスペクションしてパスを解決しようとします。中間の 1 つが null であるか、それ以上インスペクションできない (間違った) 型の場合は、null が返されます。
      パラメーター:
      source - インスペクションするソース。null にすることはできません。
      key - 検索するキー。null にすることはできません。
      戻り値:
      null でもかまいません。
      導入:
      4.1
    • hasValue

      public static boolean hasValue(Bson bson, FieldName fieldName)
    • hasValue

      public static boolean hasValue(Bson bson, StringSE key)
      Returns whether the underlying bson has a value (null or non-null) for the given key.
      パラメーター:
      bson - インスペクションするソース。null にすることはできません。
      key - 検索するキー。null にすることはできません。
      戻り値:
      null 以外の値が存在しない場合は true。
      導入:
      3.0.8
    • asBson

      public static Bson asBson(ObjectSE source)
      Returns the given source object as Bson, i.e. Document s and maps as is or throw IllegalArgumentExceptionSE
      パラメーター:
      source -
      戻り値:
      変換 / キャストされたソースオブジェクト。
      例外:
      IllegalArgumentExceptionSE - if source cannot be converted/cast to Bson
      導入:
      3.2.3
      関連事項:
    • supportsBson

      public static boolean supportsBson(ObjectSE source)
      Returns the given source can be used/converted as Bson
      パラメーター:
      source -
      戻り値:
      true if the given source can be converted to Bson
      導入:
      3.2.3
    • asCollection

      public static CollectionSE<?> asCollection(ObjectSE source)
      指定されたオブジェクトを CollectionSE として返します。ソースがすでに CollectionSE である場合は CollectionSE をそのまま返し、配列を CollectionSE に変換するか、それ以外の場合は単に単一要素のコレクションを作成します。
      パラメーター:
      source - null であってはなりません。
      戻り値:
      決して null にはなりません。
      導入:
      3.2
    • mapValues

      public static Document mapValues(Document source, BiFunctionSE<StringSE,ObjectSE,ObjectSE> valueMapper)
    • mapEntries

      public static Document mapEntries(Document source, FunctionSE<Map.EntrySE<StringSE,ObjectSE>, StringSE> keyMapper, FunctionSE<Map.EntrySE<StringSE,ObjectSE>, ObjectSE> valueMapper)