Package org.mongojack

Class DBRef<T,​K>


  • public class DBRef<T,​K>
    extends Object
    A database reference object
    Since:
    1.2
    Author:
    James Roper
    • Constructor Detail

      • DBRef

        public DBRef​(K id,
                     Class<T> objectClass,
                     String collectionName,
                     String databaseName)
        Construct a new database reference with the given id and collection name
        Parameters:
        id - The id of the database reference to construct
        objectClass - The value class of the collection that the ref is pointing to
        collectionName - The name of the collection
        databaseName - The database name holding the collection (optional)
      • DBRef

        public DBRef​(K id,
                     Class<T> type)
              throws MongoJsonMappingException
        Construct a new database reference with the given id and type. The type must be annotated with MongoCollection, so that the name can be worked out.
        Parameters:
        id - The id of the database reference to construct
        type - The type of the object
        Throws:
        MongoJsonMappingException - If no MongoCollection annotation is found on the type
    • Method Detail

      • getId

        public K getId()
        Get the ID of this object
        Returns:
        The ID of this object
      • getObjectClass

        public Class<T> getObjectClass()
      • getCollectionName

        public String getCollectionName()
        Get the name of the collection this object lives in
        Returns:
        The name of the collection this object lives in
      • getDatabaseName

        public String getDatabaseName()