static Collection<?> getCollectionFromDocumentList(Metamodel metamodel, BasicDBList documentList,
            Class embeddedCollectionClass, Class embeddedObjectClass, Set<Attribute> columns)
    {
        Collection<Object> embeddedCollection = null;
        if (embeddedCollectionClass.equals(Set.class))
        {
            embeddedCollection = new HashSet<Object>();
        }
        else if (embeddedCollectionClass.equals(List.class))
        {
            embeddedCollection = new ArrayList<Object>();
        }
        else
        {
            throw new PersistenceException(
                    "Invalid collection class " + embeddedCollectionClass + "; only Set and List allowed");
        }

        for (Object dbObj : documentList)
        {
            try
            {
                Object obj = embeddedObjectClass.newInstance();
                embeddedCollection.add(getObjectFromDocument(metamodel, (BasicDBObject) dbObj, columns, obj));
            }
            catch (InstantiationException e)
            {
                throw new PersistenceException(e);
            }
            catch (IllegalAccessException e)
            {
                throw new PersistenceException(e);
            }
        }

        return embeddedCollection;
    }
static Collection < ? > getCollectionFromDocumentList ( Metamodel metamodel , BasicDBList documentList , Class embeddedCollectionClass , Class embeddedObjectClass , Set < Attribute > columns ) { Collection < Object > embeddedCollection = null ; if ( embeddedCollectionClass . equals ( Set . class ) ) { embeddedCollection = new HashSet < Object > ( ) ; } else if ( embeddedCollectionClass . equals ( List . class ) ) { embeddedCollection = new ArrayList < Object > ( ) ; } else { throw new PersistenceException ( "Invalid collection class " + embeddedCollectionClass + "; only Set and List allowed" ) ; } for ( Object dbObj : documentList ) { try { Object obj = embeddedObjectClass . newInstance ( ) ; embeddedCollection . add ( getObjectFromDocument ( metamodel , ( BasicDBObject ) dbObj , columns , obj ) ) ; } catch ( InstantiationException e ) { throw new PersistenceException ( e ) ; } catch ( IllegalAccessException e ) { throw new PersistenceException ( e ) ; } } return embeddedCollection ; }
Creates a collection of <code>embeddedObjectClass</code> instances
wherein each element is java object representation of MongoDB document
object contained in <code>documentList</code>. Field names are determined
from <code>columns</code>.

@param documentList
the document list
@param embeddedCollectionClass
the embedded collection class
@param embeddedObjectClass
the embedded object class
@param columns
the columns
@param metamodel
@return the collection from document list