Class TypeConverter

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TypeConverter()  
      protected TypeConverter​(java.lang.Class... types)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract java.lang.Object decode​(java.lang.Class<?> targetClass, java.lang.Object fromDBObject, MappedField optionalExtraInfo)
      decode the DBObject and provide the corresponding java (type-safe) object
      NOTE: optionalExtraInfo might be null
      java.lang.Object decode​(java.lang.Class targetClass, java.lang.Object fromDBObject)
      decode the DBObject and provide the corresponding java (type-safe) object
      java.lang.Object encode​(java.lang.Object value)
      encode the type safe java object into the corresponding DBObject
      java.lang.Object encode​(java.lang.Object value, MappedField optionalExtraInfo)
      encode the (type-safe) java object into the corresponding DBObject
      boolean equals​(java.lang.Object obj)  
      Mapper getMapper()  
      java.lang.Class[] getSupportTypes()
      Deprecated.
      use #getSupportedTypes()
      int hashCode()  
      protected boolean isSupported​(java.lang.Class<?> c, MappedField optionalExtraInfo)
      checks if the class is supported for this converter.
      protected boolean oneOf​(java.lang.Class f, java.lang.Class... classes)
      checks if Class f is in classes *
      protected boolean oneOfClasses​(java.lang.Class f, java.lang.Class[] classes)
      checks if Class f is in classes *
      void setMapper​(Mapper mapper)
      Sets the Mapper to use.
      void setSupportedTypes​(java.lang.Class[] supportedTypes)
      Sets the types supported by this converter.
      void setSupportTypes​(java.lang.Class[] supportTypes)
      Deprecated.
      use #setSupportedTypes(Class[])
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeConverter

        protected TypeConverter()
      • TypeConverter

        protected TypeConverter​(java.lang.Class... types)
    • Method Detail

      • decode

        public final java.lang.Object decode​(java.lang.Class targetClass,
                                             java.lang.Object fromDBObject)
        decode the DBObject and provide the corresponding java (type-safe) object
        Parameters:
        targetClass - the class to create and populate
        fromDBObject - the DBObject to use when populating the new instance
        Returns:
        the new instance
      • decode

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

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

        public java.lang.Object encode​(java.lang.Object value,
                                       MappedField optionalExtraInfo)
        encode the (type-safe) java object into the corresponding DBObject
        Parameters:
        value - The object to encode
        optionalExtraInfo - the MappedField that contains the metadata useful for decoding
        Returns:
        the encoded version of the object
      • getMapper

        public Mapper getMapper()
        Returns:
        the mapper used by the converter
      • setMapper

        public void setMapper​(Mapper mapper)
        Sets the Mapper to use.
        Parameters:
        mapper - the Mapper to use
      • getSupportTypes

        @Deprecated
        public java.lang.Class[] getSupportTypes()
        Deprecated.
        use #getSupportedTypes()
        Returns:
        an array of supported convertable types
      • setSupportTypes

        @Deprecated
        public void setSupportTypes​(java.lang.Class[] supportTypes)
        Deprecated.
        use #setSupportedTypes(Class[])
        Parameters:
        supportTypes - the types this converter supports
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • isSupported

        protected boolean isSupported​(java.lang.Class<?> c,
                                      MappedField optionalExtraInfo)
        checks if the class is supported for this converter.
      • oneOf

        protected boolean oneOf​(java.lang.Class f,
                                java.lang.Class... classes)
        checks if Class f is in classes *
      • oneOfClasses

        protected boolean oneOfClasses​(java.lang.Class f,
                                       java.lang.Class[] classes)
        checks if Class f is in classes *
      • setSupportedTypes

        public void setSupportedTypes​(java.lang.Class[] supportedTypes)
        Sets the types supported by this converter.
        Parameters:
        supportedTypes - the types this converter supports