private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }