Java Code Examples for org.bson.BsonReader#readObjectId()

The following examples show how to use org.bson.BsonReader#readObjectId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BsonCodecRepoTest.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Override
public Somebody decode(BsonReader reader, DecoderContext decoderContext) {
  reader.readStartDocument();
  ObjectId id = reader.readObjectId("_id");
  String prop1 = reader.readString("prop1");
  Date date = new Date(reader.readDateTime("dateChanged"));
  reader.readEndDocument();
  return ImmutableSomebody.builder().id(id).prop1(prop1).date(date).build();
}
 
Example 2
Source File: JacksonRepoTest.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public ObjectId deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
  final BsonReader reader = ((BsonParser) parser).unwrap();
  return reader.readObjectId();
}