Ejemplo n.º 1
0
  @Override
  public void encode(BsonWriter writer, Ra t, EncoderContext ec) {
    writer.writeStartDocument();
    Codec<LocalDate> dateCodec = codecRegistry.get(LocalDate.class);
    writer.writeName("name");
    writer.writeString(t.getName());
    writer.writeName("pointsTaken");
    writer.writeDouble(t.getPointsTaken());
    writer.writeName("previousDutyDay");
    ec.encodeWithChildContext(dateCodec, writer, t.getPreviousDutyDay());

    // Write Blackout Date Array
    writer.writeName("blackoutDates");
    writer.writeStartArray();
    for (LocalDate blackoutDate : t.getBlackoutDates()) {
      ec.encodeWithChildContext(dateCodec, writer, blackoutDate);
    }
    writer.writeEndArray();

    // Write Duty Day Array
    writer.writeName("dutyDays");
    writer.writeStartArray();
    for (LocalDate dutyDay : t.getDutyDays()) {
      ec.encodeWithChildContext(dateCodec, writer, dutyDay);
    }
    writer.writeEndArray();
    writer.writeEndDocument();
  }
Ejemplo n.º 2
0
 private void writeIterable(
     final BsonWriter writer, final Iterable<Object> list, final EncoderContext encoderContext) {
   writer.writeStartArray();
   for (final Object value : list) {
     writeValue(writer, encoderContext, value);
   }
   writer.writeEndArray();
 }