@Override
    public Pattern read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      if (in instanceof BsonReader) {
        final String pattern = ((BsonReader) in).unwrap()
                .readRegularExpression().getPattern();
        return Pattern.compile(pattern);
      }
      return Pattern.compile(in.nextString());
    }
Use this adapter (not registered by factory, default Gson adapter is used otherwise) to
delagate marshaling of {@link BigDecimal} to {@link Decimal128} type in mongo.
@return {@code BigDecimal <==> Decimal128} adapter
mongo/src/org/immutables/mongo/types/TypeAdapters.java