Package org.bson.codecs
Class EncoderContext
java.lang.Object
org.bson.codecs.EncoderContext
The context for encoding values to BSON.
- Since:
- 3.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A builder forEncoderContext
instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic EncoderContext.Builder
builder()
Create a builder.<T> void
encodeWithChildContext
(Encoder<T> encoder, BsonWriter writer, T value) Creates a child context based on this and serializes the value with it to the writer.Gets a child context based on this.boolean
Returns true if the value to be encoded is a document that will be put in a MongoDB collection.
-
Method Details
-
builder
Create a builder.- Returns:
- the builder
-
isEncodingCollectibleDocument
public boolean isEncodingCollectibleDocument()Returns true if the value to be encoded is a document that will be put in a MongoDB collection. Encoders for such documents might choose to act differently when encoding such as documents, e.g. by re-ordering the fields in some way (like encoding the _id field first).- Returns:
- true if the value to be encoded is a document that will be put in a MongoDB collection
-
encodeWithChildContext
Creates a child context based on this and serializes the value with it to the writer.- Type Parameters:
T
- the type of the value- Parameters:
encoder
- the encoder to encode value withwriter
- the writer to encode tovalue
- the value to encode
-
getChildContext
Gets a child context based on this.- Returns:
- the child context
-