Package com.mongodb.connection
Class ConnectionId
java.lang.Object
com.mongodb.connection.ConnectionId
An immutable connection identifier of a connection to a MongoDB server.
Contains a locally created id and if available the MongoDB server created connection id
- Since:
- 3.0
-
Constructor Summary
ConstructorDescriptionConnectionId
(ServerId serverId) Construct an instance with the given server id.ConnectionId
(ServerId serverId, int localValue, Integer serverValue) Construct an instance with the given serverId, localValue, and serverValue. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Gets the locally created id value for the connectionGets the server id.Gets the server generated id value for the connection or null if not set.int
hashCode()
toString()
withServerValue
(int serverValue) Creates a new connectionId with the set server value
-
Constructor Details
-
ConnectionId
Construct an instance with the given server id.- Parameters:
serverId
- the server id- Since:
- 3.8
-
ConnectionId
Construct an instance with the given serverId, localValue, and serverValue.Useful for testing, but generally prefer
withServerValue(int)
- Parameters:
serverId
- the server idlocalValue
- the local valueserverValue
- the server value, which may be null- Since:
- 3.11
- See Also:
-
-
Method Details
-
withServerValue
Creates a new connectionId with the set server value- Parameters:
serverValue
- the server value- Returns:
- the new connection id
- Since:
- 3.8
-
getServerId
Gets the server id.- Returns:
- the server id
-
getLocalValue
public int getLocalValue()Gets the locally created id value for the connection- Returns:
- the locally created id value for the connection
-
getServerValue
Gets the server generated id value for the connection or null if not set.- Returns:
- the server generated id value for the connection or null if not set.
-
equals
-
hashCode
public int hashCode() -
toString
-