Class EncoderContext



  • public final class EncoderContext
    extends Object
    The context for encoding values to BSON.
    Since:
    3.0
    See Also:
    Encoder
    • Method Detail

      • isEncodingCollectibleDocument

        public boolean isEncodingCollectibleDocument​()
        Returns true if the 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

        public <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.
        Type Parameters:
        T - the type of the value
        Parameters:
        encoder - the encoder to encode value with
        writer - the writer to encode to
        value - the value to encode
      • getChildContext

        public EncoderContext getChildContext​()
        Gets a child context based on this.
        Returns:
        the child context