Hi Simone,
No, Jackson does not come in with built in serialisers for Guava classes. However, it shouldn't be hard to write one, off the top of my head, it would look roughly like this (note, I've never used the Guava optional interface, so I'm guessing what it looks like):
public class OptionalSerializer extends JsonSerializer<Optional<String>> {
public void serialize(JsonGenerator jgen, Optional<String> option) {
if (option.isDefined()) {
jgen.writeString(option.getValue());
} else {
jgen.writeNull();
}
}
}
If you wanted to generically handle all types of Optional, it would get a little more complex, but not impossible. You can then register this serialiser with an ObjectMapper, and then pass that object mapper to the JacksonDBCollection.wrap() method (don't forget to call MongoJacksonModule.configure(objectMapper) first!).
Cheers,
James