POJOPropertiesCollector类中collectAll()来进行要序列化的字段的收集。
这个方法的_removeUnwantedProperties()调用会将@JsonIgnore注解和 vo里实现方法给移除掉。
protected void collectAll()
{
LinkedHashMap<String, POJOPropertyBuilder> props = new LinkedHashMap<String, POJOPropertyBuilder>();
// First: gather basic data
_addFields(props); //2022年3月6日19:20:21 添加这个实体类的成员变量
_addMethods(props);// 添加所有的get方法并且 赋好判断值(是否要忽略)
// 25-Jan-2016, tatu: Avoid introspecting (constructor-)creators for non-static
// inner classes, see [databind#1502]
if (!_classDef.isNonStaticInnerClass()) {
_addCreators(props);
}
_addInjectables(props);
/**
* Method for collecting basic information on all fields found
*/
protected void _addMethods(Map<String, POJOPropertyBuilder> props)
{
final AnnotationIntrospector ai = _annotationIntrospector;
for (AnnotatedMethod m : _classDef.memberMethods()) {
/* For methods, handling differs between getters and setters; and
* we will also only consider entries that either follow the bean
* naming convention or are explicitly marked: just being visible
* is not enough (unlike with fields)
*/
int argCount = m.getParameterCount();
if (argCount == 0) { // getters (including 'any getter')
//不是get开头的方法名的方法也会走这边。这个方法判断的。具体没再细看了2022年3月6日19:25:25
_addGetterMethod(props, m, ai);
} else if (argCount == 1) { // setters
_addSetterMethod(props, m, ai);
} else if (argCount == 2) { // any getter?
if (ai != null) {
if (Boolean.TRUE.equals(ai.hasAnySetter(m))) {
if (_anySetters == null) {
_anySetters = new LinkedList<AnnotatedMethod>();
}
_anySetters.add(m);
}
}
}
}
}