Skip to content

Commit d27f4a6

Browse files
committed
Polishing.
Refine deprecations. Original pull request: #4986 See #4969
1 parent c3695d9 commit d27f4a6

File tree

1 file changed

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

1 file changed

+27
-12
lines changed

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

Lines changed: 27 additions & 12 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,8 +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
*/
108+
@Deprecated(since = "4.5.1", forRemoval = true)
106109
public OutOperation uniqueKey(@Nullable String key) {
107110

108111
Document uniqueKey = key == null ? null : BsonUtils.toDocumentOrElse(key, it -> new Document(it, 1));
@@ -126,8 +129,10 @@ public OutOperation uniqueKey(@Nullable String key) {
126129
* @param fields must not be {@literal null}.
127130
* @return new instance of {@link OutOperation}.
128131
* @since 2.2
129-
* @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.
130134
*/
135+
@Deprecated(since = "4.5.1", forRemoval = true)
131136
public OutOperation uniqueKeyOf(Iterable<String> fields) {
132137

133138
Assert.notNull(fields, "Fields must not be null");
@@ -145,8 +150,10 @@ public OutOperation uniqueKeyOf(Iterable<String> fields) {
145150
* @param mode must not be {@literal null}.
146151
* @return new instance of {@link OutOperation}.
147152
* @since 2.2
148-
* @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.
149155
*/
156+
@Deprecated(since = "4.5.1", forRemoval = true)
150157
public OutOperation mode(OutMode mode) {
151158

152159
Assert.notNull(mode, "Mode must not be null");
@@ -160,8 +167,10 @@ public OutOperation mode(OutMode mode) {
160167
* @return new instance of {@link OutOperation}.
161168
* @see OutMode#REPLACE_COLLECTION
162169
* @since 2.2
163-
* @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.
164172
*/
173+
@Deprecated(since = "4.5.1", forRemoval = true)
165174
public OutOperation replaceCollection() {
166175
return mode(OutMode.REPLACE_COLLECTION);
167176
}
@@ -173,8 +182,10 @@ public OutOperation replaceCollection() {
173182
* @return new instance of {@link OutOperation}.
174183
* @see OutMode#REPLACE
175184
* @since 2.2
176-
* @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.
177187
*/
188+
@Deprecated(since = "4.5.1", forRemoval = true)
178189
public OutOperation replaceDocuments() {
179190
return mode(OutMode.REPLACE);
180191
}
@@ -186,16 +197,18 @@ public OutOperation replaceDocuments() {
186197
* @return new instance of {@link OutOperation}.
187198
* @see OutMode#INSERT
188199
* @since 2.2
189-
* @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.
190202
*/
203+
@Deprecated(since = "4.5.1", forRemoval = true)
191204
public OutOperation insertDocuments() {
192205
return mode(OutMode.INSERT);
193206
}
194207

195208
@Override
196209
public Document toDocument(AggregationOperationContext context) {
197210

198-
if (!requiresMongoDb42Format()) {
211+
if (!requiresExtendedFormat()) {
199212
if (!StringUtils.hasText(databaseName)) {
200213
return new Document(getOperator(), collectionName);
201214
}
@@ -223,7 +236,7 @@ public String getOperator() {
223236
return "$out";
224237
}
225238

226-
private boolean requiresMongoDb42Format() {
239+
private boolean requiresExtendedFormat() {
227240
return mode != null || uniqueKey != null;
228241
}
229242

@@ -232,9 +245,10 @@ private boolean requiresMongoDb42Format() {
232245
*
233246
* @author Christoph Strobl
234247
* @since 2.2
235-
* @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.
236250
*/
237-
@Deprecated
251+
@Deprecated(since = "4.5.1", forRemoval = true)
238252
public enum OutMode {
239253

240254
/**
@@ -248,7 +262,8 @@ public enum OutMode {
248262
REPLACE("replaceDocuments"),
249263

250264
/**
251-
* 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.
252267
*/
253268
REPLACE_COLLECTION("replaceCollection");
254269

0 commit comments

Comments
 (0)