add some syntax sugar using statics

This commit is contained in:
Mark Pollack
2011-04-07 19:28:24 -04:00
parent 9bd1257b6a
commit dd5b66f60e
2 changed files with 22 additions and 1 deletions

View File

@@ -32,6 +32,17 @@ public class Query {
private int limit;
/**
* Static factory method to create a Query using the provided criteria
*
* @param key
* @return
*/
public static Query query(Criteria critera) {
return new Query(critera);
}
public Query() {
}

View File

@@ -30,6 +30,16 @@ public class Update {
private HashMap<String, Object> criteria = new LinkedHashMap<String, Object>();
/**
* Static factory method to create an Update using the provided key
*
* @param key
* @return
*/
public static Update update(String key, Object value) {
return new Update().set(key, value);
}
/**
* Update using the $set update modifier
*
@@ -41,7 +51,7 @@ public class Update {
criteria.put("$set", Collections.singletonMap(key, convertValueIfNecessary(value)));
return this;
}
/**
* Update using the $unset update modifier
*