All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.mjorm.DBRefUtil Maven / Gradle / Ivy

package com.googlecode.mjorm;

import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBObject;
import com.mongodb.DBRef;

/**
 * Utilities for working with {@link DBRef} objects.
 */
public final class DBRefUtil {

	/**
	 * Does nothing.
	 */
	private DBRefUtil() { }
	static { new DBRefUtil(); }

	/**
	 * Inspects the given {@link DBObject} recursively and fetches it's
	 * DBRefs recursively for the given {@link DB}.
	 * @param db the {@link DB}
	 * @param obj the {@link DBObject}
	 * @return the {@link DBObject} that was passed in
	 */
	public static DBObject fetchDBRefs(DB db, DBObject obj) {

		// BasicDBList
		if (BasicDBList.class.isInstance(obj)) {
			BasicDBList list = BasicDBList.class.cast(obj);
			for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy