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


Java JsonTypeInfo.include方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonTypeInfo.include方法的典型用法代码示例。如果您正苦于以下问题:Java JsonTypeInfo.include方法的具体用法?Java JsonTypeInfo.include怎么用?Java JsonTypeInfo.include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.annotation.JsonTypeInfo的用法示例。


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

示例1: saveType

import com.fasterxml.jackson.annotation.JsonTypeInfo; //导入方法依赖的package包/类
private void saveType(String path, T object, KeyValueStorage storage) {
    Class<?> clazz = object.getClass();
    String name = PROP_TYPE;
    String value = clazz.getName();
    JsonTypeInfo typeInfo = AnnotationUtils.findAnnotation(clazz, JsonTypeInfo.class);
    if (typeInfo != null && !clazz.equals(typeInfo.defaultImpl())) {
        JsonTypeInfo.As include = typeInfo.include();
        if(include != JsonTypeInfo.As.PROPERTY &&
           include != JsonTypeInfo.As.EXTERNAL_PROPERTY /* it for capability with jackson oddities */) {
            throw new IllegalArgumentException("On " + clazz + " mapping support only " + JsonTypeInfo.As.PROPERTY + " but find: " + include);
        }
        name = getPropertyName(typeInfo);
        value = getJsonType(clazz, typeInfo);
    }
    storage.set(KvUtils.join(path, name), value);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:17,代码来源:NodeMapping.java

示例2: _findTypeResolver

import com.fasterxml.jackson.annotation.JsonTypeInfo; //导入方法依赖的package包/类
protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> paramMapperConfig, Annotated paramAnnotated, JavaType paramJavaType)
{
  JsonTypeInfo localJsonTypeInfo = (JsonTypeInfo)paramAnnotated.getAnnotation(JsonTypeInfo.class);
  JsonTypeResolver localJsonTypeResolver = (JsonTypeResolver)paramAnnotated.getAnnotation(JsonTypeResolver.class);
  Object localObject;
  if (localJsonTypeResolver != null)
  {
    if (localJsonTypeInfo == null)
      return null;
    localObject = paramMapperConfig.typeResolverBuilderInstance(paramAnnotated, localJsonTypeResolver.value());
  }
  else
  {
    if (localJsonTypeInfo == null)
      return null;
    if (localJsonTypeInfo.use() == JsonTypeInfo.Id.NONE)
      return _constructNoTypeResolverBuilder();
    localObject = _constructStdTypeResolverBuilder();
  }
  JsonTypeIdResolver localJsonTypeIdResolver = (JsonTypeIdResolver)paramAnnotated.getAnnotation(JsonTypeIdResolver.class);
  TypeIdResolver localTypeIdResolver1;
  if (localJsonTypeIdResolver == null)
    localTypeIdResolver1 = null;
  else
    localTypeIdResolver1 = paramMapperConfig.typeIdResolverInstance(paramAnnotated, localJsonTypeIdResolver.value());
  TypeIdResolver localTypeIdResolver2 = localTypeIdResolver1;
  if (localTypeIdResolver1 != null)
    localTypeIdResolver2.init(paramJavaType);
  TypeResolverBuilder localTypeResolverBuilder1 = ((TypeResolverBuilder)localObject).init(localJsonTypeInfo.use(), localTypeIdResolver2);
  JsonTypeInfo.As localAs1 = localJsonTypeInfo.include();
  JsonTypeInfo.As localAs2 = localAs1;
  if ((localAs1 == JsonTypeInfo.As.EXTERNAL_PROPERTY) && ((paramAnnotated instanceof AnnotatedClass)))
    localAs2 = JsonTypeInfo.As.PROPERTY;
  TypeResolverBuilder localTypeResolverBuilder2 = localTypeResolverBuilder1.inclusion(localAs2).typeProperty(localJsonTypeInfo.property());
  Class localClass = localJsonTypeInfo.defaultImpl();
  if (localClass != JsonTypeInfo.None.class)
    localTypeResolverBuilder2 = localTypeResolverBuilder2.defaultImpl(localClass);
  return localTypeResolverBuilder2.typeIdVisibility(localJsonTypeInfo.visible());
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:40,代码来源:JacksonAnnotationIntrospector.java

示例3: getInheritance

import com.fasterxml.jackson.annotation.JsonTypeInfo; //导入方法依赖的package包/类
private void getInheritance(ClassInformation information, ReflectClass<?> cls) {
    JsonTypeName typeName = cls.getAnnotation(JsonTypeName.class);
    if (information.typeName == null) {
        information.typeName = "";
    }
    if (typeName != null) {
        information.typeName = typeName.value();
    }
    if (information.typeName.isEmpty()) {
        information.typeName = getUnqualifiedName(cls.getName());
    }

    JsonTypeInfo typeInfo = cls.getAnnotation(JsonTypeInfo.class);
    if (typeInfo != null) {
        String defaultProperty = "";
        switch (typeInfo.use()) {
            case CLASS:
                information.inheritance.value = InheritanceValue.CLASS;
                defaultProperty = "@class";
                break;
            case MINIMAL_CLASS:
                information.inheritance.value = InheritanceValue.MINIMAL_CLASS;
                defaultProperty = "@c";
                break;
            case NAME:
                information.inheritance.value = InheritanceValue.NAME;
                defaultProperty = "@type";
                break;
            case NONE:
                information.inheritance.value = InheritanceValue.NONE;
                break;
            default:
                diagnostics.warning(null, "{{t0}}: unsupported value " + typeInfo.use() + " in {{t1}}",
                        cls, JsonTypeInfo.Id.class);
                break;
        }

        if (information.inheritance.value != InheritanceValue.NONE) {
            switch (typeInfo.include()) {
                case PROPERTY:
                    information.inheritance.key = InheritanceKey.PROPERTY;
                    break;
                case WRAPPER_ARRAY:
                    information.inheritance.key = InheritanceKey.WRAPPER_ARRAY;
                    break;
                case WRAPPER_OBJECT:
                    information.inheritance.key = InheritanceKey.WRAPPER_OBJECT;
                    break;
                default:
                    diagnostics.warning(null, "{{t0}}: unsupported value " + typeInfo.include()
                            + " in {{t1}}", cls, JsonTypeInfo.As.class);
                    break;
            }
        }

        if (information.inheritance.key == InheritanceKey.PROPERTY) {
            String property = typeInfo.property();
            if (property.isEmpty()) {
                property = defaultProperty;
            }
            information.inheritance.propertyName = property;
        }
    }
}
 
开发者ID:konsoletyper,项目名称:teavm-flavour,代码行数:65,代码来源:ClassInformationProvider.java

示例4: isSupported

import com.fasterxml.jackson.annotation.JsonTypeInfo; //导入方法依赖的package包/类
private static boolean isSupported(JsonTypeInfo jsonTypeInfo) {
    return jsonTypeInfo != null &&
            jsonTypeInfo.include() == JsonTypeInfo.As.PROPERTY &&
            (jsonTypeInfo.use() == JsonTypeInfo.Id.NAME || jsonTypeInfo.use() == JsonTypeInfo.Id.CLASS);
}
 
开发者ID:vojtechhabarta,项目名称:typescript-generator,代码行数:6,代码来源:Jackson2Parser.java


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