/** * Alternate constructor used in cases where property information is not needed, * only class info. */ protected BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass classDef, List<BeanPropertyDefinition> props) { super(type); _propCollector = null; _config = config; // NOTE: null config only for some pre-constructed types if (_config == null) { _annotationIntrospector = null; } else { _annotationIntrospector = _config.getAnnotationIntrospector(); } _classInfo = classDef; _properties = props; }
/** * @since 2.7 */ public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config, AnnotatedMember member, PropertyName name, PropertyMetadata metadata, JsonInclude.Value inclusion) { return new SimpleBeanPropertyDefinition(config.getAnnotationIntrospector(), member, name, metadata, inclusion); }
protected BasicBeanDescription(POJOPropertiesCollector coll, JavaType type, AnnotatedClass classDef) { super(type); _propCollector = coll; _config = coll.getConfig(); // NOTE: null config only for some pre-constructed types if (_config == null) { _annotationIntrospector = null; } else { _annotationIntrospector = _config.getAnnotationIntrospector(); } _classInfo = classDef; }
/** * Method for finding out all reachable subtypes for given type, * such that access is by type id, * typically needed for deserialization (converting from type id to type). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedClass baseType) { // for backwards compatibility... return collectAndResolveSubtypes(baseType, config, config.getAnnotationIntrospector()); }
/** * Method for finding out all reachable subtypes for given type, * such that access is by type, * typically needed for serialization (converting from type to type name). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedClass baseType) { // for backwards compatibility... return collectAndResolveSubtypes(baseType, config, config.getAnnotationIntrospector()); }
/** * Method for finding out all reachable subtypes for a property specified * by given element (method or field), * such that access is by type, * typically needed for serialization (converting from type to type name). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { // for backwards compatibility... return collectAndResolveSubtypes(property, config, config.getAnnotationIntrospector(), baseType); }
/** * Method for finding out all reachable subtypes for a property specified * by given element (method or field), * such that access is by type id, * typically needed for deserialization (converting from type id to type). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { // for backwards compatibility... return collectAndResolveSubtypes(property, config, config.getAnnotationIntrospector(), baseType); }
@Override public List<PropertyName> findAliases(MapperConfig<?> config) { List<PropertyName> aliases = _aliases; if (aliases == null) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); if (intr != null) { aliases = intr.findPropertyAliases(getMember()); } if (aliases == null) { aliases = Collections.emptyList(); } _aliases = aliases; } return aliases; } }
/** * Method called to create instance for virtual properties. * * @since 2.5 */ public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config, AnnotatedMember member, PropertyName name, PropertyMetadata metadata, JsonInclude.Include inclusion) { JsonInclude.Value inclValue = ((inclusion == null) || (inclusion == JsonInclude.Include.USE_DEFAULTS)) ? EMPTY_INCLUDE : JsonInclude.Value.construct(inclusion, null); return new SimpleBeanPropertyDefinition(config.getAnnotationIntrospector(), member, name, metadata, inclValue); }
public static EnumValues constructFromName(MapperConfig<?> config, Class<Enum<?>> enumClass) { // Enum types with per-instance sub-classes need special handling Class<? extends Enum<?>> enumCls = ClassUtil.findEnumType(enumClass); Enum<?>[] enumValues = enumCls.getEnumConstants(); if (enumValues == null) { throw new IllegalArgumentException("Cannot determine enum constants for Class "+enumClass.getName()); } String[] names = config.getAnnotationIntrospector().findEnumValues(enumCls, enumValues, new String[enumValues.length]); SerializableString[] textual = new SerializableString[enumValues.length]; for (int i = 0, len = enumValues.length; i < len; ++i) { Enum<?> en = enumValues[i]; String name = names[i]; if (name == null) { name = en.name(); } textual[en.ordinal()] = config.compileString(name); } return new EnumValues(enumClass, textual); }
/** * @since 2.2 */ public static SimpleBeanPropertyDefinition construct(MapperConfig<?> config, AnnotatedMember member) { return new SimpleBeanPropertyDefinition(config.getAnnotationIntrospector(), member, PropertyName.construct(member.getName()), null, EMPTY_INCLUDE); }
@Override public JsonFormat.Value findPropertyFormat(MapperConfig<?> config, Class<?> baseType) { JsonFormat.Value v0 = config.getDefaultPropertyFormat(baseType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); if ((intr == null) || (_member == null)) { return v0; } JsonFormat.Value v = intr.findFormat(_member); if (v == null) { return v0; } return v0.withOverrides(v); }
AnnotatedClassResolver(MapperConfig<?> config, Class<?> cls, MixInResolver r) { _config = config; _type = null; _class = cls; _mixInResolver = r; _bindings = TypeBindings.emptyBindings(); if (config == null) { _intr = null; _primaryMixin = null; } else { _intr = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; _primaryMixin = _config.findMixInClassFor(_class); } }
AnnotatedClassResolver(MapperConfig<?> config, JavaType type, MixInResolver r) { _config = config; _type = type; _class = type.getRawClass(); _mixInResolver = r; _bindings = type.getBindings(); _intr = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; _primaryMixin = _config.findMixInClassFor(_class); }
protected POJOPropertiesCollector collectPropertiesWithBuilder(MapperConfig<?> config, JavaType type, MixInResolver r, boolean forSerialization) { AnnotatedClass ac = _resolveAnnotatedClass(config, type, r); AnnotationIntrospector ai = config.isAnnotationProcessingEnabled() ? config.getAnnotationIntrospector() : null; JsonPOJOBuilder.Value builderConfig = (ai == null) ? null : ai.findPOJOBuilderConfig(ac); String mutatorPrefix = (builderConfig == null) ? JsonPOJOBuilder.DEFAULT_WITH_PREFIX : builderConfig.withPrefix; return constructPropertyCollector(config, ac, type, forSerialization, mutatorPrefix); }
@Override public JsonInclude.Value findPropertyInclusion(MapperConfig<?> config, Class<?> baseType) { JsonInclude.Value v0 = config.getDefaultInclusion(baseType, _type.getRawClass()); AnnotationIntrospector intr = config.getAnnotationIntrospector(); if ((intr == null) || (_member == null)) { return v0; } JsonInclude.Value v = intr.findPropertyInclusion(_member); if (v == null) { return v0; } return v0.withOverrides(v); }
@Override public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedClass type) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); HashMap<NamedType, NamedType> subtypes = new HashMap<NamedType, NamedType>(); // then consider registered subtypes (which have precedence over annotations) if (_registeredSubtypes != null) { Class<?> rawBase = type.getRawType(); for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolve(curr, subtype, config, ai, subtypes); } } } // and then check subtypes via annotations from base type (recursively) NamedType rootType = new NamedType(type.getRawType(), null); _collectAndResolve(type, rootType, config, ai, subtypes); return new ArrayList<NamedType>(subtypes.values()); }
protected POJOPropertiesCollector(MapperConfig<?> config, boolean forSerialization, JavaType type, AnnotatedClass classDef, String mutatorPrefix) { _config = config; _stdBeanNaming = config.isEnabled(MapperFeature.USE_STD_BEAN_NAMING); _forSerialization = forSerialization; _type = type; _classDef = classDef; _mutatorPrefix = (mutatorPrefix == null) ? "set" : mutatorPrefix; if (config.isAnnotationProcessingEnabled()) { _useAnnotations = true; _annotationIntrospector = _config.getAnnotationIntrospector(); } else { _useAnnotations = false; _annotationIntrospector = AnnotationIntrospector.nopInstance(); } _visibilityChecker = _config.getDefaultVisibilityChecker(type.getRawClass(), classDef); }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = PropertyName.construct(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
@Override public JsonInclude.Value findPropertyInclusion(MapperConfig<?> config, Class<?> baseType) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedMember member = getMember(); if (member == null) { JsonInclude.Value def = config.getDefaultPropertyInclusion(baseType); return def; } JsonInclude.Value v0 = config.getDefaultInclusion(baseType, member.getRawType()); if (intr == null) { return v0; } JsonInclude.Value v = intr.findPropertyInclusion(member); if (v0 == null) { return v; } return v0.withOverrides(v); }