mongovalues.JsBoolCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongo-values Show documentation
Show all versions of mongo-values Show documentation
Set of codecs to add support for json-values in the Java MongoDB driver, abstracting the process of
decoding a BSON into a JsObj and encoding a JsObj into a BSON.
The newest version!
package mongovalues;
import jsonvalues.JsBool;
import org.bson.BsonReader;
import org.bson.BsonWriter;
import org.bson.codecs.BooleanCodec;
import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
class JsBoolCodec implements Codec {
private static final BooleanCodec boolCodec = new BooleanCodec();
@Override
public void encode(final BsonWriter writer, final JsBool jsBool, final EncoderContext encoderContext) {
boolCodec.encode(writer, jsBool.value, encoderContext);
}
@Override
public JsBool decode(final BsonReader reader, final DecoderContext decoderContext) {
return boolCodec.decode(reader,
decoderContext) ? JsBool.TRUE : JsBool.FALSE;
}
@Override
public Class getEncoderClass() {
return JsBool.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy