public DBRef keyToDBRef ( final Key key ) { if ( key == null ) { return null ; } if ( key . getType ( ) == null && key . getCollection ( ) == null ) { throw new IllegalStateException ( "How can it be missing both?" ) ; } if ( key . getCollection ( ) == null ) { key . setCollection ( getCollectionName ( key . getType ( ) ) ) ; } Object id = key . getId ( ) ; if ( isMapped ( id . getClass ( ) ) ) { id = toMongoObject ( id , true ) ; } return new DBRef ( key . getCollection ( ) , id ) ; }
Converts a Key to a DBRef