{
boolean autodetect = config.isEnabled(DeserializationConfig.Feature.AUTO_DETECT_SETTERS);
Map<String,AnnotatedMethod> setters = beanDesc.findSetters(autodetect);
// Also, do we have a fallback "any" setter? If so, need to bind
{
AnnotatedMethod anyM = beanDesc.findAnySetter();
if (anyM != null) {
deser.setAnySetter(constructAnySetter(config, anyM));
}
}
/* No setters? Should we proceed here? It may well be ok, if
* there are factory methods or such.
*/
//if (setters.isEmpty() && anySetter == null) ...
// These are all valid setters, but we do need to introspect bit more
for (Map.Entry<String,AnnotatedMethod> en : setters.entrySet()) {
AnnotatedMethod setter = en.getValue();
SettableBeanProperty prop = constructSettableProperty(config, en.getKey(), setter);
if (prop != null) {
deser.addProperty(prop);
}
}
/* As per [JACKSON-88], may also need to consider getters
* for Map/Collection properties
*/
if (config.isEnabled(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS)) {
/* Hmmh. We have to assume that 'use getters as setters' also
* implies 'yes, do auto-detect these getters'? (if not, we'd
* need to add AUTO_DETECT_GETTERS to deser config too, not
* just ser config)
*/
Map<String,AnnotatedMethod> getters = beanDesc.findGetters(true, setters.keySet());
for (Map.Entry<String,AnnotatedMethod> en : getters.entrySet()) {
AnnotatedMethod getter = en.getValue();
// should only consider Collections and Maps, for now?
Class<?> rt = getter.getReturnType();
if (Collection.class.isAssignableFrom(rt)
|| Map.class.isAssignableFrom(rt)) {
deser.addProperty(constructSetterlessProperty(config, en.getKey(), getter));
}
}