@Override protected void _collectAndResolve(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, AnnotationIntrospector ai, HashMap<NamedType, NamedType> collectedSubtypes) { super._collectAndResolve(annotatedType, resolveAutoValue(namedType), config, ai, collectedSubtypes); }
@Override public void registerSubtypes(Class<?>... classes) { if (locked) { throw new UnsupportedOperationException("This object is immutable"); } else { super.registerSubtypes(classes); } }
@Override public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedClass baseType) { final Class<?> rawBase = baseType.getRawType(); Set<Class<?>> typesHandled = new HashSet<Class<?>>(); Map<String,NamedType> byName = new LinkedHashMap<String,NamedType>(); NamedType rootType = new NamedType(rawBase, null); _collectAndResolveByTypeId(baseType, rootType, config, typesHandled, byName); if (_registeredSubtypes != null) { for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName); } } } return _combineNamedAndUnnamed(rawBase, typesHandled, byName); }
_subtypeResolver = new StdSubtypeResolver(); RootNameLookup rootNames = new RootNameLookup();
@Override protected void _collectAndResolveByTypeId(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, Set<Class<?>> typesHandled, Map<String, NamedType> byName) { super._collectAndResolveByTypeId(annotatedType, resolveAutoValue(namedType), config, typesHandled, byName); }
private static SerializationConfig getSerializationConfig() { SimpleMixInResolver mixins = new SimpleMixInResolver(null); BaseSettings DEFAULT_BASE = new BaseSettings( null, // cannot share global ClassIntrospector any more (2.5+) new JacksonAnnotationIntrospector(), null, TypeFactory.defaultInstance(), null, StdDateFormat.instance, null, Locale.getDefault(), null, // to indicate "use Jackson default TimeZone" (UTC since Jackson 2.7) Base64Variants.getDefaultVariant() // 2.1 ); BaseSettings base = DEFAULT_BASE.withClassIntrospector(new BasicClassIntrospector()); return new SerializationConfig(base, new StdSubtypeResolver(), mixins, new RootNameLookup(), new ConfigOverrides()); }
/** * Method called to find subtypes for a specific type (class), using * type id as the unique key (in case of conflicts). */ protected void _collectAndResolveByTypeId(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, Set<Class<?>> typesHandled, Map<String,NamedType> byName) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); if (!namedType.hasName()) { String name = ai.findTypeName(annotatedType); if (name != null) { namedType = new NamedType(namedType.getType(), name); } } if (namedType.hasName()) { byName.put(namedType.getName(), namedType); } // only check subtypes if this type hadn't yet been handled if (typesHandled.add(namedType.getType())) { Collection<NamedType> st = ai.findSubtypes(annotatedType); if (st != null && !st.isEmpty()) { for (NamedType subtype : st) { AnnotatedClass subtypeClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolveByTypeId(subtypeClass, subtype, config, typesHandled, byName); } } } }
private static SerializationConfig getSerializationConfig() { SimpleMixInResolver mixins = new SimpleMixInResolver(null); BaseSettings DEFAULT_BASE = new BaseSettings( null, // cannot share global ClassIntrospector any more (2.5+) new JacksonAnnotationIntrospector(), null, TypeFactory.defaultInstance(), null, StdDateFormat.instance, null, Locale.getDefault(), null, // to indicate "use Jackson default TimeZone" (UTC since Jackson 2.7) Base64Variants.getDefaultVariant() // 2.1 ); BaseSettings base = DEFAULT_BASE.withClassIntrospector(new BasicClassIntrospector()); return new SerializationConfig(base, new StdSubtypeResolver(), mixins, new RootNameLookup(), new ConfigOverrides()); }
@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()); }
@Override public void registerSubtypes(NamedType... types) { if (locked) { throw new UnsupportedOperationException("This object is immutable"); } else { super.registerSubtypes(types); } } }
AnnotatedClass ac = AnnotatedClassResolver.resolveWithoutSuperTypes(config, rawBase); _collectAndResolveByTypeId(ac, rootType, config, typesHandled, byName); for (NamedType nt : st) { ac = AnnotatedClassResolver.resolveWithoutSuperTypes(config, nt.getType()); _collectAndResolveByTypeId(ac, nt, config, typesHandled, byName); AnnotatedClass curr = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName); return _combineNamedAndUnnamed(rawBase, typesHandled, byName);
/** * Method called to find subtypes for a specific type (class), using * type id as the unique key (in case of conflicts). */ protected void _collectAndResolveByTypeId(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, Set<Class<?>> typesHandled, Map<String,NamedType> byName) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); if (!namedType.hasName()) { String name = ai.findTypeName(annotatedType); if (name != null) { namedType = new NamedType(namedType.getType(), name); } } if (namedType.hasName()) { byName.put(namedType.getName(), namedType); } // only check subtypes if this type hadn't yet been handled if (typesHandled.add(namedType.getType())) { Collection<NamedType> st = ai.findSubtypes(annotatedType); if (st != null && !st.isEmpty()) { for (NamedType subtype : st) { AnnotatedClass subtypeClass = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), config); _collectAndResolveByTypeId(subtypeClass, subtype, config, typesHandled, byName); } } } }
private static SerializationConfig getSerializationConfig() { SimpleMixInResolver mixins = new SimpleMixInResolver(null); BaseSettings DEFAULT_BASE = new BaseSettings( null, // cannot share global ClassIntrospector any more (2.5+) new JacksonAnnotationIntrospector(), null, TypeFactory.defaultInstance(), null, StdDateFormat.instance, null, Locale.getDefault(), null, // to indicate "use Jackson default TimeZone" (UTC since Jackson 2.7) Base64Variants.getDefaultVariant() // 2.1 ); BaseSettings base = DEFAULT_BASE.withClassIntrospector(new BasicClassIntrospector()); return new SerializationConfig(base, new StdSubtypeResolver(), mixins, new RootNameLookup(), new ConfigOverrides()); }
AnnotatedClass curr = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolve(curr, subtype, config, ai, collected); AnnotatedClass ac = AnnotatedClassResolver.resolveWithoutSuperTypes(config, nt.getType()); _collectAndResolve(ac, nt, config, ai, collected); _collectAndResolve(ac, rootType, config, ai, collected);
@Override public void registerSubtypes(Class<?>... classes) { NamedType[] types = new NamedType[classes.length]; for (int i = 0, len = classes.length; i < len; ++i) { types[i] = new NamedType(classes[i]); } registerSubtypes(types); }
@Override public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedClass baseType) { final Class<?> rawBase = baseType.getRawType(); Set<Class<?>> typesHandled = new HashSet<Class<?>>(); Map<String,NamedType> byName = new LinkedHashMap<String,NamedType>(); NamedType rootType = new NamedType(rawBase, null); _collectAndResolveByTypeId(baseType, rootType, config, typesHandled, byName); if (_registeredSubtypes != null) { for (NamedType subtype : _registeredSubtypes) { // is it a subtype of root type? if (rawBase.isAssignableFrom(subtype.getType())) { // yes AnnotatedClass curr = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolveByTypeId(curr, subtype, config, typesHandled, byName); } } } return _combineNamedAndUnnamed(rawBase, typesHandled, byName); }
/** * Method called to find subtypes for a specific type (class), using * type id as the unique key (in case of conflicts). */ protected void _collectAndResolveByTypeId(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, Set<Class<?>> typesHandled, Map<String,NamedType> byName) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); if (!namedType.hasName()) { String name = ai.findTypeName(annotatedType); if (name != null) { namedType = new NamedType(namedType.getType(), name); } } if (namedType.hasName()) { byName.put(namedType.getName(), namedType); } // only check subtypes if this type hadn't yet been handled if (typesHandled.add(namedType.getType())) { Collection<NamedType> st = ai.findSubtypes(annotatedType); if (st != null && !st.isEmpty()) { for (NamedType subtype : st) { AnnotatedClass subtypeClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolveByTypeId(subtypeClass, subtype, config, typesHandled, byName); } } } }
private static SerializationConfig getSerializationConfig() { SimpleMixInResolver mixins = new SimpleMixInResolver(null); BaseSettings DEFAULT_BASE = new BaseSettings( null, // cannot share global ClassIntrospector any more (2.5+) new JacksonAnnotationIntrospector(), null, TypeFactory.defaultInstance(), null, StdDateFormat.instance, null, Locale.getDefault(), null, // to indicate "use Jackson default TimeZone" (UTC since Jackson 2.7) Base64Variants.getDefaultVariant() // 2.1 ); BaseSettings base = DEFAULT_BASE.withClassIntrospector(new BasicClassIntrospector()); return new SerializationConfig(base, new StdSubtypeResolver(), mixins, new RootNameLookup(), new ConfigOverrides()); }
AnnotatedClass subtypeClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, subtype.getType()); _collectAndResolve(subtypeClass, subtype, config, ai, collectedSubtypes);
@Override // since 2.9 public void registerSubtypes(Collection<Class<?>> subtypes) { int len = subtypes.size(); NamedType[] types = new NamedType[len]; int i = 0; for (Class<?> subtype : subtypes) { types[i++] = new NamedType(subtype); } registerSubtypes(types); }