DBCollection.setObjectClass() and DBCollection.setInternalClass() offer a convinient way to convert DBObjects to custom objects without using reflection.
However there is no proper way of converting DBObjects contained in arrays to custom objects. This is due to the way the driver retrieves "internal classes" by path.
For instance, having:
public class Question implements DBObject {
/* ... */
public List<Answer> answers;
}
public class Answer implements DBObject {
/* ... */
}
The way to convert "answers" array items to Answer instances is as follows:
collection.setInternalClass("answers.0", Answer.class);
collection.setInternalClass("answers.1", Answer.class);
collection.setInternalClass("answers.2", Answer.class);
and so on...
it would be nice to have a way of setting a custom class for all items inside an array? Maybe using setInternalClass or a new method:
collection.setInternalClass("answers.$", Answer.class);
collection.setCollectionItemClass("answers", Answer.class);