Class MongoDBSerializationHelper

java.lang.Object
org.nuxeo.directory.mongodb.MongoDBSerializationHelper

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

  • Method Details

    • 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
    • valueToBson

      public static Object valueToBson(Object value, Type type)
      Cast an object according to its instance ans its type
      Parameters:
      value - the object to transform
      type - the object type
      Returns:
      the BSON object
      Since:
      9.2
    • listToBson

      protected static List<Object> listToBson(List<Object> values)
    • 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
    • bsonToValue

      protected static Serializable bsonToValue(Object value)
    • scalarToSerializableClass

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

      protected static Serializable scalarToSerializable(Object value)