use of org.bson.codecs.jsr310.Jsr310CodecProvider in project immutables by immutables.
the class BsonModule method defaultRegistry.
private static CodecRegistry defaultRegistry() {
CodecRegistry standard = CodecRegistries.fromProviders(new BsonValueCodecProvider(), new Jsr310CodecProvider());
// avoid codecs for String / Long / Boolean etc. They're already handled by jackson
// choose the ones which need to be natively serialized in non-JSON format (BSON)
CodecRegistry others = CodecRegistries.fromCodecs(new ObjectIdCodec(), new DateCodec(), new UuidCodec(UuidRepresentation.JAVA_LEGACY), new Decimal128Codec(), new PatternCodec(), new BigDecimalCodec(), new ByteArrayCodec());
return CodecRegistries.fromRegistries(standard, others);
}
use of org.bson.codecs.jsr310.Jsr310CodecProvider in project immutables by immutables.
the class JavaTimeTest method setUp.
@Before
public void setUp() {
CodecRegistry registry = CodecRegistries.fromProviders(new Jsr310CodecProvider());
TypeAdapterFactory factory = GsonCodecs.delegatingTypeAdapterFactory(registry);
TypeAdapter<Date> dateTypeAdapter = GsonCodecs.typeAdapterFromCodec(new DateCodec());
gson = new GsonBuilder().registerTypeAdapter(Date.class, dateTypeAdapter).registerTypeAdapterFactory(factory).create();
}
Aggregations