List of usage examples for com.mongodb.client MongoCollection withDocumentClass
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz);
From source file:org.mongojack.JacksonMongoCollection.java
License:Apache License
private JacksonMongoCollection(com.mongodb.client.MongoCollection<?> mongoCollection, ObjectMapper objectMapper, Class<T> valueClass, Class<?> view) { this.objectMapper = objectMapper == null ? DEFAULT_OBJECT_MAPPER : objectMapper; this.view = view; JacksonCodecRegistry jacksonCodecRegistry = new JacksonCodecRegistry(this.objectMapper, this.view); jacksonCodecRegistry.addCodecForClass(valueClass); this.mongoCollection = mongoCollection.withDocumentClass(valueClass) .withCodecRegistry(jacksonCodecRegistry); ;/*from w w w .j av a2s.c om*/ this.valueClass = valueClass; this.type = this.objectMapper.constructType(valueClass); }