Skip to content

Commit dd5b66f

Browse files
author
Mark Pollack
committed
add some syntax sugar using statics
1 parent 9bd1257 commit dd5b66f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Query.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ public class Query {
3232

3333
private int limit;
3434

35+
36+
/**
37+
* Static factory method to create a Query using the provided criteria
38+
*
39+
* @param key
40+
* @return
41+
*/
42+
public static Query query(Criteria critera) {
43+
return new Query(critera);
44+
}
45+
3546
public Query() {
3647
}
3748

spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/query/Update.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public enum Position {
3030

3131
private HashMap<String, Object> criteria = new LinkedHashMap<String, Object>();
3232

33+
/**
34+
* Static factory method to create an Update using the provided key
35+
*
36+
* @param key
37+
* @return
38+
*/
39+
public static Update update(String key, Object value) {
40+
return new Update().set(key, value);
41+
}
42+
3343
/**
3444
* Update using the $set update modifier
3545
*
@@ -41,7 +51,7 @@ public Update set(String key, Object value) {
4151
criteria.put("$set", Collections.singletonMap(key, convertValueIfNecessary(value)));
4252
return this;
4353
}
44-
54+
4555
/**
4656
* Update using the $unset update modifier
4757
*

0 commit comments

Comments
 (0)