Class Mapper


  • @Deprecated
    public class Mapper
    extends java.lang.Object
    Deprecated.
    this class will be internalized in 2.0
    Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String CLASS_NAME_FIELDNAME
      Deprecated. 
      static java.lang.String ID_KEY
      Deprecated.
      use "_id" directly
      static java.lang.String IGNORED_FIELDNAME
      Deprecated.
      Special name that can never be used.
    • Constructor Summary

      Constructors 
      Constructor Description
      Mapper()
      Deprecated.
      Creates a Mapper with default options
      Mapper​(MapperOptions opts)
      Deprecated.
      Creates a Mapper with the given options.
      Mapper​(MapperOptions options, Mapper mapper)
      Deprecated.
      Creates a new Mapper with the given options and a Mapper to copy.
    • Field Detail

      • ID_KEY

        @Deprecated
        public static final java.lang.String ID_KEY
        Deprecated.
        use "_id" directly
        The @Id field name that is stored with mongodb.
        See Also:
        Constant Field Values
      • IGNORED_FIELDNAME

        public static final java.lang.String IGNORED_FIELDNAME
        Deprecated.
        Special name that can never be used. Used as default for some fields to indicate default state.
        See Also:
        Constant Field Values
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • CLASS_NAME_FIELDNAME

        @Deprecated
        public static final java.lang.String CLASS_NAME_FIELDNAME
        Deprecated.
        Special field used by morphia to support various possibly loading issues; will be replaced when discriminators are implemented to support polymorphism
        See Also:
        Constant Field Values
    • Constructor Detail

      • Mapper

        public Mapper​(MapperOptions opts)
        Deprecated.
        Creates a Mapper with the given options.
        Parameters:
        opts - the options to use
      • Mapper

        public Mapper()
        Deprecated.
        Creates a Mapper with default options
        See Also:
        MapperOptions
      • Mapper

        public Mapper​(MapperOptions options,
                      Mapper mapper)
        Deprecated.
        Creates a new Mapper with the given options and a Mapper to copy. This is effectively a copy constructor that allows a developer to override the options.
        Parameters:
        options - the options to use
        mapper - the collection of MappedClasses to add
    • Method Detail

      • addMappedClass

        public MappedClass addMappedClass​(java.lang.Class c)
        Deprecated.
        Creates a MappedClass and validates it.
        Parameters:
        c - the Class to map
        Returns:
        the MappedClass for the given Class
      • createEntityCache

        public EntityCache createEntityCache()
        Deprecated.
        Creates a cache for tracking entities seen during processing
        Returns:
        the cache
      • fromDBObject

        @Deprecated
        public <T> T fromDBObject​(Datastore datastore,
                                  java.lang.Class<T> entityClass,
                                  com.mongodb.DBObject dbObject,
                                  EntityCache cache)
        Deprecated.
        no replacement is planned
        Converts a DBObject back to a type-safe java object (POJO)
        Type Parameters:
        T - the type of the entity
        Parameters:
        datastore - the Datastore to use when fetching this reference
        entityClass - The type to return, or use; can be overridden by the @see Mapper.CLASS_NAME_FIELDNAME in the DBObject
        dbObject - the DBObject containing the document from mongodb
        cache - the EntityCache to use
        Returns:
        the new entity
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getSubTypes

        public java.util.List<MappedClass> getSubTypes​(MappedClass mc)
        Deprecated.
        Finds any subtypes for the given MappedClass.
        Parameters:
        mc - the parent type
        Returns:
        the list of subtypes
        Since:
        1.3
      • fromDb

        @Deprecated
        public <T> T fromDb​(Datastore datastore,
                            com.mongodb.DBObject dbObject,
                            T entity,
                            EntityCache cache)
        Deprecated.
        no replacement is planned
        Converts a DBObject back to a type-safe java object (POJO)
        Type Parameters:
        T - the type of the entity
        Parameters:
        datastore - the Datastore to use when fetching this reference
        dbObject - the DBObject containing the document from mongodb
        entity - the instance to populate
        cache - the EntityCache to use
        Returns:
        the entity
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getClassFromCollection

        @Deprecated
        public java.lang.Class<?> getClassFromCollection​(java.lang.String collection)
        Deprecated.
        no replacement is planned
        Looks up the class mapped to a named collection.
        Parameters:
        collection - the collection name
        Returns:
        the Class mapped to this collection name
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getCollectionName

        @Deprecated
        public java.lang.String getCollectionName​(java.lang.Object object)
        Deprecated.
        no replacement is planned
        Gets the mapped collection for an object instance or Class reference.
        Parameters:
        object - the object to process
        Returns:
        the collection name
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getConverters

        public Converters getConverters()
        Deprecated.
        Returns:
        the Converters bundle this Mapper uses
      • getId

        public java.lang.Object getId​(java.lang.Object entity)
        Deprecated.
        Gets the ID value for an entity
        Parameters:
        entity - the entity to process
        Returns:
        the ID value
      • getInstanceCache

        public java.util.Map<java.lang.Class,​java.lang.Object> getInstanceCache()
        Deprecated.
        no replacement is planned
        Returns:
        the cache of instances
        Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getKey

        public <T> Key<T> getKey​(T entity)
        Deprecated.
        Gets the Key for an entity
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to process
        Returns:
        the Key
      • getKey

        public <T> Key<T> getKey​(T entity,
                                 java.lang.String collection)
        Deprecated.
        Gets the Key for an entity and a specific collection
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to process
        collection - the collection to use in the Key rather than the mapped collection as defined on the entity's class
        Returns:
        the Key
      • getKeysByManualRefs

        public <T> java.util.List<Key<T>> getKeysByManualRefs​(java.lang.Class<T> clazz,
                                                              java.util.List<java.lang.Object> refs)
        Deprecated.
        Gets the Keys for a list of objects
        Type Parameters:
        T - the type of the entity
        Parameters:
        clazz - the Class of the objects
        refs - the objects to fetch the keys for
        Returns:
        the list of Keys
      • getKeysByRefs

        public <T> java.util.List<Key<T>> getKeysByRefs​(java.util.List<com.mongodb.DBRef> refs)
        Deprecated.
        Gets the Keys for a list of objects
        Type Parameters:
        T - the type of the objects
        Parameters:
        refs - the objects to process
        Returns:
        the list of Keys
      • getMCMap

        public java.util.Map<java.lang.String,​MappedClass> getMCMap()
        Deprecated.
        Returns:
        map of MappedClasses by class name
      • getMappedClass

        public MappedClass getMappedClass​(java.lang.Object obj)
        Deprecated.
        Gets the MappedClass for the object (type). If it isn't mapped, create a new class and cache it (without validating).
        Parameters:
        obj - the object to process
        Returns:
        the MappedClass for the object given
      • getMappedClasses

        public java.util.Collection<MappedClass> getMappedClasses()
        Deprecated.
        Returns:
        collection of MappedClasses
      • getOptions

        public MapperOptions getOptions()
        Deprecated.
        Returns:
        the options used by this Mapper
      • setOptions

        public void setOptions​(MapperOptions options)
        Deprecated.
        Sets the options this Mapper should use
        Parameters:
        options - the options to use
      • isMapped

        public boolean isMapped​(java.lang.Class c)
        Deprecated.
        Checks to see if a Class has been mapped.
        Parameters:
        c - the Class to check
        Returns:
        true if the Class has been mapped
      • keyToDBRef

        public com.mongodb.DBRef keyToDBRef​(Key key)
        Deprecated.
        Converts a Key to a DBRef
        Parameters:
        key - the Key to convert
        Returns:
        the DBRef
      • manualRefToKey

        public <T> Key<T> manualRefToKey​(java.lang.Class<T> type,
                                         java.lang.Object id)
        Deprecated.
        Creates a Key for a type and an ID value
        Type Parameters:
        T - the type of the entity
        Parameters:
        type - the Class of the entity
        id - the ID value
        Returns:
        the Key
      • refToKey

        public <T> Key<T> refToKey​(com.mongodb.DBRef ref)
        Deprecated.
        Converts a DBRef to a Key
        Type Parameters:
        T - the type of the referenced entity
        Parameters:
        ref - the DBRef to convert
        Returns:
        the Key
      • toDBObject

        public com.mongodb.DBObject toDBObject​(java.lang.Object entity)
        Deprecated.
        /** Converts an entity (POJO) to a DBObject. A special field will be added to keep track of the class type.
        Parameters:
        entity - The POJO
        Returns:
        the DBObject
      • toDBObject

        public com.mongodb.DBObject toDBObject​(java.lang.Object entity,
                                               java.util.Map<java.lang.Object,​com.mongodb.DBObject> involvedObjects)
        Deprecated.
        Converts an entity (POJO) to a DBObject. A special field will be added to keep track of the class type.
        Parameters:
        entity - The POJO
        involvedObjects - A Map of (already converted) POJOs
        Returns:
        the DBObject
      • toMongoObject

        public java.lang.Object toMongoObject​(MappedField mf,
                                              MappedClass mc,
                                              java.lang.Object value)
        Deprecated.
        Converts a java object to a mongo-compatible object (possibly a DBObject for complex mappings). Very similar to toDBObject(java.lang.Object). Used (mainly) by query/update operations.
        Parameters:
        mf - the MappedField for this value
        mc - the MappedClass for this value
        value - the value to convert
        Returns:
        the MongoDB compatible object
      • updateCollection

        public java.lang.String updateCollection​(Key key)
        Deprecated.
        Updates the collection value on a Key with the mapped value on the Key's type Class
        Parameters:
        key - the Key to update
        Returns:
        the collection name on the Key
      • updateKeyAndVersionInfo

        public void updateKeyAndVersionInfo​(Datastore datastore,
                                            com.mongodb.DBObject dbObj,
                                            EntityCache cache,
                                            java.lang.Object entity)
        Deprecated.
        Updates the @Id and @Version fields.
        Parameters:
        datastore - the Datastore to use when fetching this reference
        dbObj - Value to update with; null means skip
        cache - the EntityCache
        entity - The object to update