@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
private void removeSuperSubTypes(List<NamedType> resultTypes, Class<?> superClass) { JavaType superType = _mapper.constructType(superClass); BeanDescription superBean = _mapper.getSerializationConfig().introspect(superType); final List<NamedType> superTypes = _intr.findSubtypes(superBean.getClassInfo()); if (superTypes != null) { resultTypes.removeAll(superTypes); } }
private boolean isSubtype(AnnotatedClass childClass, Class<?> parentClass) { final BeanDescription parentDesc = _mapper.getSerializationConfig().introspectClassAnnotations(parentClass); List<NamedType> subTypes =_intr.findSubtypes(parentDesc.getClassInfo()); if (subTypes == null) { return false; } for (NamedType subtype : subTypes) { final Class<?> subtypeType = subtype.getType(); if (childClass.getRawType().isAssignableFrom(subtypeType)) { return true; } } return false; }
Collection<NamedType> st = ai.findSubtypes(annotatedType); if (st != null && !st.isEmpty()) { for (NamedType subtype : st) {
/** * 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); } } } }
Collection<NamedType> st = ai.findSubtypes(property); if (st != null) { for (NamedType nt : st) {
Collection<NamedType> st = ai.findSubtypes(property); if (st != null) { for (NamedType nt : st) {
private boolean resolveSubtypes(Schema model, BeanDescription bean, ModelConverterContext context) { final List<NamedType> types = _intr.findSubtypes(bean.getClassInfo()); if (types == null) { return false;
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
@Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; }
AnnotationIntrospector annotationInspector = new JacksonAnnotationIntrospector(); JavaType superClassType = TypeFactory.defaultInstance().uncheckedSimpleType(Animal.class); AnnotatedClass annotatedClass = AnnotatedClass.construct(superClassType,new ObjectMapper().getSerializationConfig()); List<NamedType> subtypes = annotationInspector.findSubtypes(annotatedClass);
public static List<Class> getSubtypeClasses(ObjectMapper mapper, Class c) { return getSubtypeClasses(mapper.getDeserializationConfig(), c); } public static List<Class> getSubtypeClasses(MapperConfig config, Class c) { AnnotationIntrospector ai = config.getAnnotationIntrospector(); AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(c, ai, config); List<NamedType> subtypes = ai.findSubtypes(ac); List<Class> result = new ArrayList<>(); if (subtypes != null) { for (NamedType subtype : subtypes) { result.add(subtype.getType()); } } return result; }
private void removeSuperSubTypes(List<NamedType> resultTypes, Class<?> superClass) { JavaType superType = _mapper.constructType(superClass); BeanDescription superBean = _mapper.getSerializationConfig().introspect(superType); final List<NamedType> superTypes = _intr.findSubtypes(superBean.getClassInfo()); if (superTypes != null) { resultTypes.removeAll(superTypes); } }
private boolean isSubtype(AnnotatedClass childClass, Class<?> parentClass) { final BeanDescription parentDesc = _mapper.getSerializationConfig().introspectClassAnnotations(parentClass); List<NamedType> subTypes =_intr.findSubtypes(parentDesc.getClassInfo()); if (subTypes == null) { return false; } for (NamedType subtype : subTypes) { final Class<?> subtypeType = subtype.getType(); if (childClass.getRawType().isAssignableFrom(subtypeType)) { return true; } } return false; }
/** * 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); } } } }
/** * 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); } } } }