Skip to content

Commit 271e93f

Browse files
committed
Polishing.
Refine deprecations. Original pull request: #4986 See #4969
1 parent 7f39691 commit 271e93f

File tree

1 file changed

+27
-18
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation

1 file changed

+27
-18
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/OutOperation.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public OutOperation(String outCollectionName) {
4949
/**
5050
* @param databaseName Optional database name the target collection is located in. Can be {@literal null}.
5151
* @param collectionName Collection name to export the results. Must not be {@literal null}. Can be {@literal null}.
52-
* @param uniqueKey Optional unique key spec identify a document in the to collection for replacement or merge.
52+
* @param uniqueKey Optional unique key spec identify a document in the {@code to} collection for replacement or
53+
* merge.
5354
* @param mode The mode for merging the aggregation pipeline output with the target collection. Can be
5455
* {@literal null}. {@literal null}.
5556
* @since 2.2
@@ -101,9 +102,10 @@ public OutOperation in(@Nullable String database) {
101102
* @param key can be {@literal null}. Server uses {@literal _id} when {@literal null}.
102103
* @return new instance of {@link OutOperation}.
103104
* @since 2.2
104-
* @deprecated no longer applicable for MongoDB 5+
105+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
106+
* removed with MongoDB 5, use {@link MergeOperation} instead.
105107
*/
106-
@Deprecated
108+
@Deprecated(since = "4.3.13")
107109
public OutOperation uniqueKey(@Nullable String key) {
108110

109111
Document uniqueKey = key == null ? null : BsonUtils.toDocumentOrElse(key, it -> new Document(it, 1));
@@ -127,9 +129,10 @@ public OutOperation uniqueKey(@Nullable String key) {
127129
* @param fields must not be {@literal null}.
128130
* @return new instance of {@link OutOperation}.
129131
* @since 2.2
130-
* @deprecated no longer applicable for MongoDB 5+
132+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
133+
* removed with MongoDB 5, use {@link MergeOperation} instead.
131134
*/
132-
@Deprecated
135+
@Deprecated(since = "4.3.13")
133136
public OutOperation uniqueKeyOf(Iterable<String> fields) {
134137

135138
Assert.notNull(fields, "Fields must not be null");
@@ -147,9 +150,10 @@ public OutOperation uniqueKeyOf(Iterable<String> fields) {
147150
* @param mode must not be {@literal null}.
148151
* @return new instance of {@link OutOperation}.
149152
* @since 2.2
150-
* @deprecated no longer applicable for MongoDB 5+
153+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
154+
* removed with MongoDB 5, use {@link MergeOperation} instead.
151155
*/
152-
@Deprecated
156+
@Deprecated(since = "4.3.13")
153157
public OutOperation mode(OutMode mode) {
154158

155159
Assert.notNull(mode, "Mode must not be null");
@@ -163,9 +167,10 @@ public OutOperation mode(OutMode mode) {
163167
* @return new instance of {@link OutOperation}.
164168
* @see OutMode#REPLACE_COLLECTION
165169
* @since 2.2
166-
* @deprecated no longer applicable for MongoDB 5+
170+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
171+
* removed with MongoDB 5, use {@link MergeOperation} instead.
167172
*/
168-
@Deprecated
173+
@Deprecated(since = "4.3.13")
169174
public OutOperation replaceCollection() {
170175
return mode(OutMode.REPLACE_COLLECTION);
171176
}
@@ -177,9 +182,10 @@ public OutOperation replaceCollection() {
177182
* @return new instance of {@link OutOperation}.
178183
* @see OutMode#REPLACE
179184
* @since 2.2
180-
* @deprecated no longer applicable for MongoDB 5+
185+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
186+
* removed with MongoDB 5, use {@link MergeOperation} instead.
181187
*/
182-
@Deprecated
188+
@Deprecated(since = "4.3.13")
183189
public OutOperation replaceDocuments() {
184190
return mode(OutMode.REPLACE);
185191
}
@@ -191,17 +197,18 @@ public OutOperation replaceDocuments() {
191197
* @return new instance of {@link OutOperation}.
192198
* @see OutMode#INSERT
193199
* @since 2.2
194-
* @deprecated no longer applicable for MongoDB 5+
200+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
201+
* removed with MongoDB 5, use {@link MergeOperation} instead.
195202
*/
196-
@Deprecated
203+
@Deprecated(since = "4.3.13")
197204
public OutOperation insertDocuments() {
198205
return mode(OutMode.INSERT);
199206
}
200207

201208
@Override
202209
public Document toDocument(AggregationOperationContext context) {
203210

204-
if (!requiresMongoDb42Format()) {
211+
if (!requiresExtendedFormat()) {
205212
if (!StringUtils.hasText(databaseName)) {
206213
return new Document(getOperator(), collectionName);
207214
}
@@ -229,7 +236,7 @@ public String getOperator() {
229236
return "$out";
230237
}
231238

232-
private boolean requiresMongoDb42Format() {
239+
private boolean requiresExtendedFormat() {
233240
return mode != null || uniqueKey != null;
234241
}
235242

@@ -238,9 +245,10 @@ private boolean requiresMongoDb42Format() {
238245
*
239246
* @author Christoph Strobl
240247
* @since 2.2
241-
* @deprecated no longer applicable for MongoDB 5+
248+
* @deprecated extended {@code $out} syntax was superseded by {@code $merge}. Support for the extended syntax has been
249+
* removed with MongoDB 5, use {@link MergeOperation} instead.
242250
*/
243-
@Deprecated
251+
@Deprecated(since = "4.3.13")
244252
public enum OutMode {
245253

246254
/**
@@ -254,7 +262,8 @@ public enum OutMode {
254262
REPLACE("replaceDocuments"),
255263

256264
/**
257-
* Replaces the to collection with the output from the aggregation pipeline. Cannot be in a different database.
265+
* Replaces the {@code to} collection with the output from the aggregation pipeline. Cannot be in a different
266+
* database.
258267
*/
259268
REPLACE_COLLECTION("replaceCollection");
260269

0 commit comments

Comments
 (0)