Package com.mongodb
Class ReadConcern
- java.lang.Object
-
- com.mongodb.ReadConcern
-
public final class ReadConcern extends Object
A read concern allows clients to choose a level of isolation for their reads.- Since:
- 3.2
- MongoDB documentation
- Read Concern
- Since server release
- 3.2
-
-
Field Summary
Fields Modifier and Type Field Description static ReadConcernAVAILABLEThe available read concern.static ReadConcernDEFAULTUse the servers default read concern.static ReadConcernLINEARIZABLEThe linearizable read concern.static ReadConcernLOCALThe local read concern.static ReadConcernMAJORITYThe majority read concern.static ReadConcernSNAPSHOTThe snapshot read concern.
-
Constructor Summary
Constructors Constructor Description ReadConcern(ReadConcernLevel level)Construct a new read concern
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BsonDocumentasDocument()Gets this read concern as a document.booleanequals(Object o)ReadConcernLevelgetLevel()Gets the read concern level.inthashCode()booleanisServerDefault()
-
-
-
Field Detail
-
DEFAULT
public static final ReadConcern DEFAULT
Use the servers default read concern.
-
LOCAL
public static final ReadConcern LOCAL
The local read concern.
-
MAJORITY
public static final ReadConcern MAJORITY
The majority read concern.
-
LINEARIZABLE
public static final ReadConcern LINEARIZABLE
The linearizable read concern.This read concern is only compatible with
ReadPreference.primary().- Since:
- 3.4
- Since server release
- 3.4
-
SNAPSHOT
public static final ReadConcern SNAPSHOT
The snapshot read concern.- Since:
- 3.8
- Since server release
- 4.0
-
AVAILABLE
public static final ReadConcern AVAILABLE
The available read concern.- Since:
- 3.9
- Since server release
- 3.6
-
-
Constructor Detail
-
ReadConcern
public ReadConcern(ReadConcernLevel level)
Construct a new read concern- Parameters:
level- the read concern level
-
-
Method Detail
-
getLevel
@Nullable public ReadConcernLevel getLevel()
Gets the read concern level.- Returns:
- the read concern level, which may be null (which indicates to use the server's default level)
- Since:
- 3.6
-
isServerDefault
public boolean isServerDefault()
- Returns:
- true if this is the server default read concern
-
asDocument
public BsonDocument asDocument()
Gets this read concern as a document.- Returns:
- The read concern as a BsonDocument
-
-