Package org.mongojack
Class DBRef<T,K>
- java.lang.Object
-
- org.mongojack.DBRef<T,K>
-
public class DBRef<T,K> extends Object
A database reference object- Since:
- 1.2
- Author:
- James Roper
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JacksonCollectionKey<T>
getCollectionKey()
String
getCollectionName()
Get the name of the collection this object lives inString
getDatabaseName()
K
getId()
Get the ID of this objectClass<T>
getObjectClass()
-
-
-
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 constructobjectClass
- The value class of the collection that the ref is pointing tocollectionName
- The name of the collectiondatabaseName
- 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 withMongoCollection
, so that the name can be worked out.- Parameters:
id
- The id of the database reference to constructtype
- 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
-
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()
-
getCollectionKey
public JacksonCollectionKey<T> getCollectionKey()
-
-