@Override
  public void writeNumber(BigDecimal number) throws IOException {
    if (number == null) {
      writeNull();
    } else {
      try {
        writer.writeDecimal128(new Decimal128(number));
      } catch (NumberFormatException e) {
        writer.writeString(number.toString());
      }
    }
  }
Delegates all streaming API to {@link BsonWriter}.
criteria/mongo/src/org/immutables/criteria/mongo/bson4jackson/BsonGenerator.java