當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。