当前位置: 首页>>代码示例>>Java>>正文


Java Type类代码示例

本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonSubTypes.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Type类属于com.fasterxml.jackson.annotation.JsonSubTypes包,在下文中一共展示了Type类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJsonTypeInfo

import com.fasterxml.jackson.annotation.JsonSubTypes.Type; //导入依赖的package包/类
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);
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:25,代码来源:PojoGeneratingApiVisitor.java

示例2: value

import com.fasterxml.jackson.annotation.JsonSubTypes.Type; //导入依赖的package包/类
@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();
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:CustomBuilderDeserialize.java

示例3: findSubtypes

import com.fasterxml.jackson.annotation.JsonSubTypes.Type; //导入依赖的package包/类
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;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:16,代码来源:JacksonAnnotationIntrospector.java

示例4: subclasses

import com.fasterxml.jackson.annotation.JsonSubTypes.Type; //导入依赖的package包/类
@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();
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:13,代码来源:JacksonMappingResolver.java


注:本文中的com.fasterxml.jackson.annotation.JsonSubTypes.Type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。