Class Converters

    • Constructor Detail

      • Converters

        public Converters​(Mapper mapper)
        Creates a bundle with a particular Mapper.
        Parameters:
        mapper - the Mapper to use
    • Method Detail

      • addConverter

        public TypeConverter addConverter​(java.lang.Class<? extends TypeConverter> clazz)
        Adds a TypeConverter to this bundle.
        Parameters:
        clazz - the converter to add
        Returns:
        the new instance
      • addConverter

        public TypeConverter addConverter​(TypeConverter tc)
        Add a type converter. If it is a duplicate for an existing type, it will override that type.
        Parameters:
        tc - the converter to add
        Returns:
        the TypeConverter passed in
      • decode

        public java.lang.Object decode​(java.lang.Class c,
                                       java.lang.Object fromDBObject,
                                       MappedField mf)
        decode the DBObject and provide the corresponding java (type-safe) object
        NOTE: mf might be null
        Parameters:
        c - the class to create and populate
        fromDBObject - the DBObject to use when populating the new instance
        mf - the MappedField that contains the metadata useful for decoding
        Returns:
        the new instance
      • encode

        public java.lang.Object encode​(java.lang.Object o)
        encode the type safe java object into the corresponding DBObject
        Parameters:
        o - The object to encode
        Returns:
        the encoded version of the object
      • encode

        public java.lang.Object encode​(java.lang.Class c,
                                       java.lang.Object o)
        encode the type safe java object into the corresponding DBObject
        Parameters:
        c - The type to use when encoding
        o - The object to encode
        Returns:
        the encoded version of the object
      • fromDBObject

        public void fromDBObject​(com.mongodb.DBObject dbObj,
                                 MappedField mf,
                                 java.lang.Object targetEntity)
        Creates an entity and populates its state based on the dbObject given. This method is primarily an internal method. Reliance on this method may break your application in future releases.
        Parameters:
        dbObj - the object state to use
        mf - the MappedField containing the metadata to use when decoding in to a field
        targetEntity - then entity to hold the state from the database
      • hasDbObjectConverter

        public boolean hasDbObjectConverter​(MappedField field)
        Parameters:
        field - the field to check with
        Returns:
        true if there is a converter for the type of the field
      • hasDbObjectConverter

        public boolean hasDbObjectConverter​(java.lang.Class c)
        Parameters:
        c - the type to check
        Returns:
        true if there is a converter for the type
      • hasSimpleValueConverter

        public boolean hasSimpleValueConverter​(java.lang.Object o)
        Parameters:
        o - the object/type to check
        Returns:
        true if there is a SimpleValueConverter for the type represented by o
        See Also:
        SimpleValueConverter
      • hasSimpleValueConverter

        public boolean hasSimpleValueConverter​(java.lang.Class c)
        Parameters:
        c - the type to check
        Returns:
        true if there is a SimpleValueConverter for the type represented by c
        See Also:
        SimpleValueConverter
      • hasSimpleValueConverter

        public boolean hasSimpleValueConverter​(MappedField c)
        Parameters:
        c - the type to check
        Returns:
        true if there is a SimpleValueConverter for the type represented by c
        See Also:
        SimpleValueConverter
      • isRegistered

        public boolean isRegistered​(java.lang.Class<? extends TypeConverter> tcClass)
        Parameters:
        tcClass - the type to check
        Returns:
        true if a converter of this type has been registered
      • removeConverter

        public void removeConverter​(TypeConverter tc)
        Removes the type converter.
        Parameters:
        tc - the converter to remove
      • toDBObject

        public void toDBObject​(java.lang.Object containingObject,
                               MappedField mf,
                               com.mongodb.DBObject dbObj,
                               MapperOptions opts)
        Converts an entity to a DBObject
        Parameters:
        containingObject - The object to convert
        mf - the MappedField to extract
        dbObj - the DBObject to populate
        opts - the options to apply
      • getEncoder

        protected TypeConverter getEncoder​(java.lang.Class c)