/** * Method for getting ordered list of named Creator properties. Returns an empty list is none * found. If multiple Creator methods are defined, order between properties from different methods * is undefined; however, properties for each such Creator are ordered properly relative to each * other. For the usual case of just a single Creator, named properties are thus properly ordered. */ public List<String> findCreatorPropertyNames() { List<String> names = null; for (int i = 0; i < 2; ++i) { List<? extends AnnotatedWithParams> l = (i == 0) ? getConstructors() : getFactoryMethods(); for (AnnotatedWithParams creator : l) { int argCount = creator.getParameterCount(); if (argCount < 1) continue; String name = _annotationIntrospector.findPropertyNameForParam(creator.getParameter(0)); if (name == null) continue; if (names == null) { names = new ArrayList<String>(); } names.add(name); for (int p = 1; p < argCount; ++p) { names.add(_annotationIntrospector.findPropertyNameForParam(creator.getParameter(p))); } } } if (names == null) { return Collections.emptyList(); } return names; }
/** * Method for locating all back-reference properties (setters, fields) bean has * * @since 1.6 */ public Map<String, AnnotatedMember> findBackReferenceProperties() { HashMap<String, AnnotatedMember> result = null; for (BeanPropertyDefinition property : _properties) { AnnotatedMember am = property.getMutator(); if (am == null) { continue; } AnnotationIntrospector.ReferenceProperty refDef = _annotationIntrospector.findReferenceType(am); if (refDef != null && refDef.isBackReference()) { if (result == null) { result = new HashMap<String, AnnotatedMember>(); } String refName = refDef.getName(); if (result.put(refName, am) != null) { throw new IllegalArgumentException( "Multiple back-reference properties with name '" + refName + "'"); } } } return result; }
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
/** * Method for determining whether null properties should be written out for a Bean of introspected * type. This is based on global feature (lowest priority, passed as argument) and per-class * annotation (highest priority). */ public JsonSerialize.Inclusion findSerializationInclusion(JsonSerialize.Inclusion defValue) { if (_annotationIntrospector == null) { return defValue; } return _annotationIntrospector.findSerializationInclusion(_classInfo, defValue); }