Class MongoDBSerializationHelper


  • public class MongoDBSerializationHelper
    extends Object
    Helper for serialization/deserialization of BSON objects
    Since:
    9.1
    • Method Detail

      • fieldMapToBson

        public static org.bson.Document fieldMapToBson​(String key,
                                                       Object value)
        Create a BSON object with a single field from a pair key/value
        Parameters:
        key - the key which corresponds to the field id in the object
        value - the value which corresponds to the field value in the object
        Returns:
        the new BSON object
      • fieldMapToBson

        public static org.bson.Document fieldMapToBson​(Map<String,​Object> fieldMap)
        Create a BSON object from a map
        Parameters:
        fieldMap - a map of keys/values
        Returns:
        the new BSON object
      • valueToBson

        public static Object valueToBson​(Object value)
        Cast an object according to its instance
        Parameters:
        value - the object to transform
        Returns:
        the BSON object
      • serializableToBson

        protected static Object serializableToBson​(Object value)
      • bsonToFieldMap

        public static Map<String,​Object> bsonToFieldMap​(org.bson.Document doc)
        Create a map from a BSON object
        Parameters:
        doc - the BSON object to parse
        Returns:
        the new map
      • scalarToSerializableClass

        protected static Class<?> scalarToSerializableClass​(Class<?> klass)
      • scalarToSerializable

        protected static Serializable scalarToSerializable​(Object value)