/* * Enabled aggressive block sorting */ @Override public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember object, MapperConfig<?> mapperConfig, AnnotationIntrospector annotationIntrospector, JavaType javaType) { void var4_6; if (javaType == null) { Class class_ = object.getRawType(); } else { Class class_ = javaType.getRawClass(); } HashMap<NamedType, NamedType> hashMap = new HashMap<NamedType, NamedType>(); if (this._registeredSubtypes != null) { for (NamedType namedType : this._registeredSubtypes) { if (!var4_6.isAssignableFrom(namedType.getType())) continue; this._collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(namedType.getType(), annotationIntrospector, mapperConfig), namedType, mapperConfig, annotationIntrospector, hashMap); } } if ((object = annotationIntrospector.findSubtypes((Annotated)object)) != null) { object = object.iterator(); while (object.hasNext()) { NamedType namedType = (NamedType)object.next(); this._collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(namedType.getType(), annotationIntrospector, mapperConfig), namedType, mapperConfig, annotationIntrospector, hashMap); } } object = new NamedType(var4_6, null); this._collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(var4_6, annotationIntrospector, mapperConfig), (NamedType)object, mapperConfig, annotationIntrospector, hashMap); return new ArrayList<NamedType>(hashMap.values()); }
/* * Enabled aggressive block sorting */ protected void _collectAndResolve(AnnotatedClass object, NamedType namedType, MapperConfig<?> mapperConfig, AnnotationIntrospector annotationIntrospector, HashMap<NamedType, NamedType> hashMap) { Object object2; Object object3 = namedType; if (!namedType.hasName()) { object2 = annotationIntrospector.findTypeName((AnnotatedClass)object); object3 = namedType; if (object2 != null) { object3 = new NamedType(namedType.getType(), (String)object2); } } if (hashMap.containsKey(object3)) { if (!object3.hasName() || hashMap.get(object3).hasName()) return; { hashMap.put((NamedType)object3, (NamedType)object3); } return; } else { hashMap.put((NamedType)object3, (NamedType)object3); if ((object = annotationIntrospector.findSubtypes((Annotated)object)) == null || object.isEmpty()) return; { object3 = object.iterator(); while (object3.hasNext()) { namedType = (NamedType)object3.next(); object2 = AnnotatedClass.constructWithoutSuperTypes(namedType.getType(), annotationIntrospector, mapperConfig); object = namedType; if (!namedType.hasName()) { object = new NamedType(namedType.getType(), annotationIntrospector.findTypeName((AnnotatedClass)object2)); } this._collectAndResolve((AnnotatedClass)object2, (NamedType)object, mapperConfig, annotationIntrospector, hashMap); } } } }
@Override public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass annotatedClass, MapperConfig<?> mapperConfig, AnnotationIntrospector annotationIntrospector) { HashMap<NamedType, NamedType> hashMap = new HashMap<NamedType, NamedType>(); if (this._registeredSubtypes != null) { Class class_ = annotatedClass.getRawType(); for (NamedType namedType : this._registeredSubtypes) { if (!class_.isAssignableFrom(namedType.getType())) continue; this._collectAndResolve(AnnotatedClass.constructWithoutSuperTypes(namedType.getType(), annotationIntrospector, mapperConfig), namedType, mapperConfig, annotationIntrospector, hashMap); } } this._collectAndResolve(annotatedClass, new NamedType(annotatedClass.getRawType(), null), mapperConfig, annotationIntrospector, hashMap); return new ArrayList<NamedType>(hashMap.values()); }
private AnnotatedField _findField(AnnotatedClass ac, String name) { for (AnnotatedField af : ac.fields()) { if (name.equals(af.getName())) { return af; } } return null; }
public void testRootNameAccess() throws Exception { AnnotationIntrospector ai = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); // If no @XmlRootElement, should get null (unless pkg has etc) assertNull(ai.findRootName(AnnotatedClass.construct(SimpleBean.class, ai, null))); // With @XmlRootElement, but no name, empty String PropertyName rootName = ai.findRootName(AnnotatedClass.construct(NamespaceBean.class, ai, null)); assertNotNull(rootName); assertEquals("", rootName.getSimpleName()); assertEquals("urn:class", rootName.getNamespace()); // and otherwise explicit name rootName = ai.findRootName(AnnotatedClass.construct(RootNameBean.class, ai, null)); assertNotNull(rootName); assertEquals("test", rootName.getSimpleName()); assertNull(rootName.getNamespace()); }
/** * Additional simple tests to ensure we will retain basic namespace information now that it can be * included * * @since 2.1 */ public void testNamespaces() throws Exception { JaxbAnnotationIntrospector ai = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); AnnotatedClass ac = AnnotatedClass.construct(NamespaceBean.class, ai, null); AnnotatedField af = _findField(ac, "string"); assertNotNull(af); PropertyName pn = ai.findNameForDeserialization(af); assertNotNull(pn); // JAXB seems to assert field name instead of giving "use default"... assertEquals("", pn.getSimpleName()); assertEquals("urn:method", pn.getNamespace()); }