Skip to content

Commit adae28a

Browse files
committed
Remove deprecated constructors and factory methods
JAVA-5144
1 parent 3eaaff3 commit adae28a

21 files changed

+56
-661
lines changed

driver-core/src/main/com/mongodb/MongoBulkWriteException.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.mongodb.bulk.WriteConcernError;
2222
import com.mongodb.lang.Nullable;
2323

24-
import java.util.Collections;
2524
import java.util.List;
2625
import java.util.Objects;
2726
import java.util.Set;
@@ -41,23 +40,6 @@ public class MongoBulkWriteException extends MongoServerException {
4140
private final ServerAddress serverAddress;
4241
private final WriteConcernError writeConcernError;
4342

44-
/**
45-
* Constructs a new instance.
46-
*
47-
* @param writeResult the write result
48-
* @param writeErrors the list of errors
49-
* @param writeConcernError the write concern error
50-
* @param serverAddress the server address.
51-
*
52-
* @deprecated Prefer {@link MongoBulkWriteException#MongoBulkWriteException(BulkWriteResult, List, WriteConcernError,
53-
* ServerAddress, Set)} instead
54-
*/
55-
@Deprecated
56-
public MongoBulkWriteException(final BulkWriteResult writeResult, final List<BulkWriteError> writeErrors,
57-
@Nullable final WriteConcernError writeConcernError, final ServerAddress serverAddress) {
58-
this(writeResult, writeErrors, writeConcernError, serverAddress, Collections.emptySet());
59-
}
60-
6143
/**
6244
* Constructs a new instance.
6345
*

driver-core/src/main/com/mongodb/MongoCursorNotFoundException.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ public MongoCursorNotFoundException(final long cursorId, final BsonDocument resp
4343
this.cursorId = cursorId;
4444
}
4545

46-
/**
47-
* Construct a new instance.
48-
*
49-
* @param cursorId cursor identifier
50-
* @param serverAddress server address
51-
* @deprecated Prefer {@link #MongoCursorNotFoundException(long, BsonDocument, ServerAddress)}
52-
*/
53-
@Deprecated
54-
public MongoCursorNotFoundException(final long cursorId, final ServerAddress serverAddress) {
55-
super(serverAddress, -5, "Cursor " + cursorId + " not found on server " + serverAddress);
56-
this.cursorId = cursorId;
57-
}
58-
5946
/**
6047
* Get the cursor id that wasn't found.
6148
*

driver-core/src/main/com/mongodb/MongoQueryException.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package com.mongodb;
1818

19-
import com.mongodb.lang.Nullable;
2019
import org.bson.BsonDocument;
21-
import org.bson.BsonInt32;
22-
import org.bson.BsonString;
2320

2421
/**
2522
* An exception indicating that a query operation failed on the server.
@@ -40,55 +37,4 @@ public class MongoQueryException extends MongoCommandException {
4037
public MongoQueryException(final BsonDocument response, final ServerAddress serverAddress) {
4138
super(response, serverAddress);
4239
}
43-
44-
/**
45-
* Construct an instance.
46-
*
47-
* @param address the server address
48-
* @param errorCode the error code
49-
* @param errorMessage the error message
50-
* @deprecated Prefer {@link #MongoQueryException(BsonDocument, ServerAddress)}
51-
*/
52-
@Deprecated
53-
public MongoQueryException(final ServerAddress address, final int errorCode, final String errorMessage) {
54-
this(manufactureResponse(errorCode, null, errorMessage), address);
55-
}
56-
57-
/**
58-
* Construct an instance.
59-
*
60-
* @param address the server address
61-
* @param errorCode the error code
62-
* @param errorCodeName the error code name
63-
* @param errorMessage the error message
64-
* @since 4.6
65-
* @deprecated Prefer {@link #MongoQueryException(BsonDocument, ServerAddress)}
66-
*/
67-
@Deprecated
68-
public MongoQueryException(final ServerAddress address, final int errorCode, @Nullable final String errorCodeName,
69-
final String errorMessage) {
70-
this(manufactureResponse(errorCode, errorCodeName, errorMessage), address);
71-
}
72-
73-
/**
74-
* Construct an instance from a command exception.
75-
*
76-
* @param commandException the command exception
77-
* @since 3.7
78-
* @deprecated Prefer {@link #MongoQueryException(BsonDocument, ServerAddress)}
79-
*/
80-
@Deprecated
81-
public MongoQueryException(final MongoCommandException commandException) {
82-
this(commandException.getResponse(), commandException.getServerAddress());
83-
}
84-
85-
private static BsonDocument manufactureResponse(final int errorCode, @Nullable final String errorCodeName, final String errorMessage) {
86-
BsonDocument response = new BsonDocument("ok", new BsonInt32(1))
87-
.append("code", new BsonInt32(errorCode))
88-
.append("errmsg", new BsonString(errorMessage));
89-
if (errorCodeName != null) {
90-
response.append("codeName", new BsonString(errorCodeName));
91-
}
92-
return response;
93-
}
9440
}

driver-core/src/main/com/mongodb/bulk/BulkWriteResult.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222

2323
import static com.mongodb.assertions.Assertions.assertNotNull;
24-
import static java.util.Collections.emptyList;
2524
import static java.util.Collections.unmodifiableList;
2625

2726
/**
@@ -97,36 +96,6 @@ public abstract class BulkWriteResult {
9796
*/
9897
public abstract List<BulkWriteUpsert> getUpserts();
9998

100-
/**
101-
* Create an acknowledged BulkWriteResult
102-
*
103-
* @param type the type of the write
104-
* @param count the number of documents matched
105-
* @param upserts the list of upserts
106-
* @return an acknowledged BulkWriteResult
107-
* @deprecated Prefer {@link BulkWriteResult#acknowledged(int, int, int, Integer, List, List)} instead
108-
*/
109-
@Deprecated
110-
public static BulkWriteResult acknowledged(final WriteRequest.Type type, final int count, final List<BulkWriteUpsert> upserts) {
111-
return acknowledged(type, count, 0, upserts, emptyList());
112-
}
113-
114-
/**
115-
* Create an acknowledged BulkWriteResult
116-
*
117-
* @param type the type of the write
118-
* @param count the number of documents matched
119-
* @param modifiedCount the number of documents modified, which may be null if the server was not able to provide the count
120-
* @param upserts the list of upserts
121-
* @return an acknowledged BulkWriteResult
122-
* @deprecated Prefer {@link BulkWriteResult#acknowledged(int, int, int, Integer, List, List)} instead
123-
*/
124-
@Deprecated
125-
public static BulkWriteResult acknowledged(final WriteRequest.Type type, final int count, final Integer modifiedCount,
126-
final List<BulkWriteUpsert> upserts) {
127-
return acknowledged(type, count, modifiedCount, upserts, emptyList());
128-
}
129-
13099
/**
131100
* Create an acknowledged BulkWriteResult
132101
*
@@ -146,23 +115,6 @@ public static BulkWriteResult acknowledged(final WriteRequest.Type type, final i
146115
modifiedCount, upserts, inserts);
147116
}
148117

149-
/**
150-
* Create an acknowledged BulkWriteResult
151-
*
152-
* @param insertedCount the number of documents inserted by the write operation
153-
* @param matchedCount the number of documents matched by the write operation
154-
* @param removedCount the number of documents removed by the write operation
155-
* @param modifiedCount the number of documents modified, which may not be null
156-
* @param upserts the list of upserts
157-
* @return an acknowledged BulkWriteResult
158-
* @deprecated Prefer {@link BulkWriteResult#acknowledged(int, int, int, Integer, List, List)} instead
159-
*/
160-
@Deprecated
161-
public static BulkWriteResult acknowledged(final int insertedCount, final int matchedCount, final int removedCount,
162-
final Integer modifiedCount, final List<BulkWriteUpsert> upserts) {
163-
return acknowledged(insertedCount, matchedCount, removedCount, modifiedCount, upserts, emptyList());
164-
}
165-
166118
/**
167119
* Create an acknowledged BulkWriteResult
168120
*

driver-core/src/main/com/mongodb/client/model/changestream/ChangeStreamDocument.java

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -116,105 +116,6 @@ public ChangeStreamDocument(
116116
this.extraElements = extraElements;
117117
}
118118

119-
/**
120-
* Creates a new instance
121-
*
122-
* @param operationTypeString the operation type
123-
* @param resumeToken the resume token
124-
* @param namespaceDocument the BsonDocument representing the namespace
125-
* @param destinationNamespaceDocument the BsonDocument representing the destinatation namespace
126-
* @param fullDocument the full document
127-
* @param fullDocumentBeforeChange the full document before change
128-
* @param documentKey a document containing the _id of the changed document
129-
* @param clusterTime the cluster time at which the change occured
130-
* @param updateDescription the update description
131-
* @param txnNumber the transaction number
132-
* @param lsid the identifier for the session associated with the transaction
133-
* @param wallTime the wall time of the server at the moment the change occurred
134-
* @param extraElements any extra elements that are part of the change stream document but not otherwise mapped to fields
135-
*
136-
* @since 4.7
137-
*/
138-
@Deprecated
139-
public ChangeStreamDocument(@BsonProperty("operationType") final String operationTypeString,
140-
@BsonProperty("resumeToken") final BsonDocument resumeToken,
141-
@Nullable @BsonProperty("ns") final BsonDocument namespaceDocument,
142-
@Nullable @BsonProperty("to") final BsonDocument destinationNamespaceDocument,
143-
@Nullable @BsonProperty("fullDocument") final TDocument fullDocument,
144-
@Nullable @BsonProperty("fullDocumentBeforeChange") final TDocument fullDocumentBeforeChange,
145-
@Nullable @BsonProperty("documentKey") final BsonDocument documentKey,
146-
@Nullable @BsonProperty("clusterTime") final BsonTimestamp clusterTime,
147-
@Nullable @BsonProperty("updateDescription") final UpdateDescription updateDescription,
148-
@Nullable @BsonProperty("txnNumber") final BsonInt64 txnNumber,
149-
@Nullable @BsonProperty("lsid") final BsonDocument lsid,
150-
@Nullable @BsonProperty("wallTime") final BsonDateTime wallTime,
151-
@Nullable @BsonProperty final BsonDocument extraElements) {
152-
this(operationTypeString, resumeToken, namespaceDocument, destinationNamespaceDocument, fullDocument, fullDocumentBeforeChange, documentKey,
153-
clusterTime, updateDescription, txnNumber, lsid, wallTime, null, extraElements);
154-
}
155-
156-
/**
157-
* Creates a new instance
158-
*
159-
* @param operationTypeString the operation type
160-
* @param resumeToken the resume token
161-
* @param namespaceDocument the BsonDocument representing the namespace
162-
* @param destinationNamespaceDocument the BsonDocument representing the destinatation namespace
163-
* @param fullDocument the full document
164-
* @param documentKey a document containing the _id of the changed document
165-
* @param clusterTime the cluster time at which the change occured
166-
* @param updateDescription the update description
167-
* @param txnNumber the transaction number
168-
* @param lsid the identifier for the session associated with the transaction
169-
*
170-
* @since 4.6
171-
*/
172-
@Deprecated
173-
public ChangeStreamDocument(@BsonProperty("operationType") final String operationTypeString,
174-
@BsonProperty("resumeToken") final BsonDocument resumeToken,
175-
@Nullable @BsonProperty("ns") final BsonDocument namespaceDocument,
176-
@Nullable @BsonProperty("to") final BsonDocument destinationNamespaceDocument,
177-
@Nullable @BsonProperty("fullDocument") final TDocument fullDocument,
178-
@Nullable @BsonProperty("documentKey") final BsonDocument documentKey,
179-
@Nullable @BsonProperty("clusterTime") final BsonTimestamp clusterTime,
180-
@Nullable @BsonProperty("updateDescription") final UpdateDescription updateDescription,
181-
@Nullable @BsonProperty("txnNumber") final BsonInt64 txnNumber,
182-
@Nullable @BsonProperty("lsid") final BsonDocument lsid) {
183-
this(operationTypeString, resumeToken, namespaceDocument, destinationNamespaceDocument, fullDocument, null, documentKey,
184-
clusterTime, updateDescription, txnNumber, lsid, null, null, null);
185-
}
186-
187-
/**
188-
* Creates a new instance
189-
*
190-
* @param operationType the operation type
191-
* @param resumeToken the resume token
192-
* @param namespaceDocument the BsonDocument representing the namespace
193-
* @param destinationNamespaceDocument the BsonDocument representing the destinatation namespace
194-
* @param fullDocument the full document
195-
* @param documentKey a document containing the _id of the changed document
196-
* @param clusterTime the cluster time at which the change occured
197-
* @param updateDescription the update description
198-
* @param txnNumber the transaction number
199-
* @param lsid the identifier for the session associated with the transaction
200-
*
201-
* @since 3.11
202-
*/
203-
@Deprecated
204-
public ChangeStreamDocument(final OperationType operationType,
205-
final BsonDocument resumeToken,
206-
final BsonDocument namespaceDocument,
207-
final BsonDocument destinationNamespaceDocument,
208-
final TDocument fullDocument,
209-
final BsonDocument documentKey,
210-
final BsonTimestamp clusterTime,
211-
final UpdateDescription updateDescription,
212-
final BsonInt64 txnNumber,
213-
final BsonDocument lsid) {
214-
this(operationType.getValue(), resumeToken, namespaceDocument, destinationNamespaceDocument, fullDocument, null, documentKey,
215-
clusterTime, updateDescription, txnNumber, lsid, null, null, null);
216-
}
217-
218119
/**
219120
* Returns the resumeToken
220121
*

driver-core/src/main/com/mongodb/event/CommandEvent.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,48 +56,6 @@ public CommandEvent(@Nullable final RequestContext requestContext, final long op
5656
this.operationId = operationId;
5757
}
5858

59-
/**
60-
* Construct an instance.
61-
*
62-
* @param requestContext the request context
63-
* @param operationId the operation id
64-
* @param requestId the request id
65-
* @param connectionDescription the connection description
66-
* @param commandName the command name
67-
* @since 4.10
68-
* @deprecated Prefer {@link CommandEvent#CommandEvent(RequestContext, long, int, ConnectionDescription, String, String)}
69-
*/
70-
@Deprecated
71-
public CommandEvent(@Nullable final RequestContext requestContext, final long operationId, final int requestId,
72-
final ConnectionDescription connectionDescription, final String commandName) {
73-
this(requestContext, -1, requestId, connectionDescription, "", commandName);
74-
}
75-
76-
/**
77-
* Construct an instance.
78-
* @param requestContext the request context
79-
* @param requestId the request id
80-
* @param connectionDescription the connection description
81-
* @param commandName the command name
82-
* @since 4.4
83-
* @deprecated Prefer {@link CommandEvent#CommandEvent(RequestContext, long, int, ConnectionDescription, String, String)}
84-
*/
85-
@Deprecated
86-
public CommandEvent(@Nullable final RequestContext requestContext, final int requestId,
87-
final ConnectionDescription connectionDescription, final String commandName) {
88-
this(requestContext, -1, requestId, connectionDescription, "", commandName);
89-
}
90-
91-
/**
92-
* Construct an instance.
93-
* @param requestId the request id
94-
* @param connectionDescription the connection description
95-
* @param commandName the command name
96-
*/
97-
public CommandEvent(final int requestId, final ConnectionDescription connectionDescription, final String commandName) {
98-
this(null, requestId, connectionDescription, commandName);
99-
}
100-
10159
/**
10260
* Gets the operation identifier
10361
*

0 commit comments

Comments
 (0)