opendatalab-de / geojson-jackson

GeoJson POJOs for Jackson - serialize and deserialize objects with ease
http://blog.opendatalab.de
Apache License 2.0
263 stars 94 forks source link

Support for ObjectMapper AUTO_DETECT_GETTERS and AUTO_DETECT_SETTERS set to false #63

Open ineentho opened 1 year ago

ineentho commented 1 year ago

Fixes #43

We had the same issue as #43, we create our ObjectMapper with these settings:

mapper = new ObjectMapper();
mapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false);
mapper.configure(MapperFeature.AUTO_DETECT_SETTERS, false);
...

We can easily add support for this case to this library using the following annotation to all classes that are supposed to be (de)serialized using jackson and use getters/setters:

@JsonAutoDetect(getterVisibility = Visibility.PUBLIC_ONLY, setterVisibility = Visibility.PUBLIC_ONLY)

This will not affect existing users that are using the default values of AUTODETECT*, as getterVisibility = Visibility.PUBLIC_ONLY and setterVisibility = Visibility.PUBLIC_ONLY are the defaults.