Java 类com.fasterxml.jackson.annotation.JsonSubTypes.Type 实例源码

项目:org.ops4j.ramler    文件:PojoGeneratingApiVisitor.java   
private void addJsonTypeInfo(JDefinedClass klass, ObjectTypeDeclaration type) {
    if (!context.getConfig().isJacksonTypeInfo()) {
        return;
    }
    if (type.discriminator() == null) {
        return;
    }
    List<String> derivedTypes = context.getApiModel().findDerivedTypes(type.name());
    if (derivedTypes.isEmpty()) {
        return;
    }
    JAnnotationUse typeInfo = klass.annotate(JsonTypeInfo.class);
    typeInfo.param("use", Id.NAME);
    typeInfo.param("include", As.EXISTING_PROPERTY);
    typeInfo.param("property", type.discriminator());

    JAnnotationUse subTypes = klass.annotate(JsonSubTypes.class);
    JAnnotationArrayMember typeArray = subTypes.paramArray(VALUE);

    for (String derivedType : derivedTypes) {
        JDefinedClass subtype = pkg._getClass(derivedType);
        typeArray.annotate(Type.class).param(VALUE, subtype);
    }
}
项目:GitHub    文件:CustomBuilderDeserialize.java   
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes({
    @Type(name = "I", value = Integer.class),
    @Type(name = "O", value = Double.class)
})
// the annotation will be copied to a builder setter
public abstract @Nullable Object value();
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
public List<NamedType> findSubtypes(Annotated paramAnnotated)
{
  JsonSubTypes localJsonSubTypes = (JsonSubTypes)paramAnnotated.getAnnotation(JsonSubTypes.class);
  if (localJsonSubTypes == null)
    return null;
  JsonSubTypes.Type[] arrayOfType = localJsonSubTypes.value();
  ArrayList localArrayList = new ArrayList(arrayOfType.length);
  int i = arrayOfType.length;
  for (int j = 0; j < i; j++)
  {
    JsonSubTypes.Type localType = arrayOfType[j];
    localArrayList.add(new NamedType(localType.value(), localType.name()));
  }
  return localArrayList;
}
项目:javersion    文件:JacksonMappingResolver.java   
@Nonnull
@Override
public Result<Map<TypeDescriptor, String>> subclasses(TypeDescriptor type) {
    JsonSubTypes jsonSubType = type.getAnnotation(JsonSubTypes.class);
    if (jsonSubType != null && jsonSubType.value().length > 0) {
        TypeDescriptors typeDescriptors = type.getTypeDescriptors();
        Map<TypeDescriptor, String> aliasesByTypes = asList(jsonSubType.value()).stream()
                .collect(toMap(subType -> typeDescriptors.get(subType.value()), Type::name));
        return Result.of(aliasesByTypes);
    }
    return Result.notFound();
}
项目:immutables    文件:CustomBuilderDeserialize.java   
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes({
    @Type(name = "I", value = Integer.class),
    @Type(name = "O", value = Double.class)
})
// the annotation will be copied to a builder setter
public abstract @Nullable Object value();