mongodb/mongo-java-driver — pull request #56 by wfreeman (2012-01-26 06:33:06+00:00)
Title: C# driver style Query Builder?

Using the C# QueryBuilder.cs as loose example, I built Query.java, which has a similar interface. It's more concise than the QueryBuilder.java. Also, as `Query` implements `DBObject`, it can be passed directly to the function needing it, without `.get()`.

For example: `QueryBuilder.start().or(new BasicDBObject("a",1),new BasicDBObject("b",1)).get();`
Becomes: `Query.Or(Query.EQ("a",1), Query.EQ("b",1));`

And: `QueryBuilder.start(key).is(value).and(key2).mod(Arrays.asList(2,1)).get();`
Becomes: `Query.EQ(key,value).and(Query.Mod(key2,2,1));`
Or: `Query.And(Query.EQ(key,value), Query.Mod(key2,2,1));`

I've included a QueryTest.java, which mimics all of the tests that QueryBuilderTest.java had, and a few extras for good measure. I’ve also implemented $near and $elemMatch, and a few others.

I realize that it's somewhat redundant functionality, but `QueryBuilder` isn't exactly full-featured yet--I thought you guys might be open to having two builders, or migrating to this one. What do you think?