private void ensureIndexesFromFieldsAndEmbeddedEntities(MappedClass mc, boolean background, ArrayList<MappedClass> parentMCs, ArrayList<MappedField> parentMFs) {
for (MappedField mf : mc.getMappedFields()) {
Class<?> indexedClass = (parentMCs.isEmpty() ? mc : parentMCs.get(0)).getClazz();
String field = getFullFieldName(parentMCs, parentMFs, mf);
if (mf.hasAnnotation(Indexed.class)) {
Indexed index = mf.getAnnotation(Indexed.class);
ensureIndex(indexedClass, index.name(), new BasicDBObject(field.toString(), index.value().toIndexValue()), index.unique(), index.dropDups(), index.background() ? index.background() : background, index.sparse() ? index.sparse() : false, index.expireAfterSeconds());
}
if (mf.hasAnnotation(SimpleTextIndex.class)) {
createTextIndex(mf, indexedClass, field);
}
if (!mf.isTypeMongoCompatible() && !mf.hasAnnotation(Reference.class) && !mf.hasAnnotation(Serialized.class)) {
ArrayList<MappedClass> newParentClasses = (ArrayList<MappedClass>) parentMCs.clone();
ArrayList<MappedField> newParents = (ArrayList<MappedField>) parentMFs.clone();
newParentClasses.add(mc);
newParents.add(mf);
ensureIndexes(mapr.getMappedClass(mf.isSingleValue() ? mf.getType() : mf.getSubClass()), background, newParentClasses, newParents);
}
}
}