code: public <T> Key<T> refToKey(final DBRef ref) {
          return ref == null ? null : new Key<T>((Class<? extends T>) getClassFromCollection(ref.getCollectionName()),
              ref.getCollectionName(), ref.getId());
      }
docs: Converts a DBRef to a Key
  
  @param ref the DBRef to convert
  @param <T> the type of the referenced entity
  @return the Key