Skip to content

Commit 541c43b

Browse files
Polishing.
Use Method reference for in-/exclusion update javadoc since tags. Original Pull Request: #4668
1 parent d2a9744 commit 541c43b

File tree

1 file changed

+4
-10
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query

1 file changed

+4
-10
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Field.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public Field projectAs(MongoExpression expression, String field) {
125125
* @since 3.1
126126
*/
127127
public Field include(String... fields) {
128-
129128
return include(Arrays.asList(fields));
130129
}
131130

@@ -134,15 +133,13 @@ public Field include(String... fields) {
134133
*
135134
* @param fields the document field names to be included.
136135
* @return {@code this} field projection instance.
136+
* @since 4.4
137137
*/
138138
public Field include(Collection<String> fields) {
139139

140140
Assert.notNull(fields, "Keys must not be null");
141141

142-
for (String key : fields) {
143-
criteria.put(key, 1);
144-
}
145-
142+
fields.forEach(this::include);
146143
return this;
147144
}
148145

@@ -169,7 +166,6 @@ public Field exclude(String field) {
169166
* @since 3.1
170167
*/
171168
public Field exclude(String... fields) {
172-
173169
return exclude(Arrays.asList(fields));
174170
}
175171

@@ -178,15 +174,13 @@ public Field exclude(String... fields) {
178174
*
179175
* @param fields the document field names to be excluded.
180176
* @return {@code this} field projection instance.
177+
* @since 4.4
181178
*/
182179
public Field exclude(Collection<String> fields) {
183180

184181
Assert.notNull(fields, "Keys must not be null");
185182

186-
for (String key : fields) {
187-
criteria.put(key, 0);
188-
}
189-
183+
fields.forEach(this::exclude);
190184
return this;
191185
}
192186

0 commit comments

Comments
 (0)