Java 类com.fasterxml.jackson.annotation.JsonTypeInfo.Id 实例源码

项目: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);
    }
}
项目:QuizUpWinner    文件:StdTypeResolverBuilder.java   
public StdTypeResolverBuilder init(JsonTypeInfo.Id paramId, TypeIdResolver paramTypeIdResolver)
{
  if (paramId == null)
    throw new IllegalArgumentException("idType can not be null");
  this._idType = paramId;
  this._customIdResolver = paramTypeIdResolver;
  this._typeProperty = paramId.getDefaultPropertyName();
  return this;
}
项目:QuizUpWinner    文件:JacksonAnnotationIntrospector.java   
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());
}
项目:gwt-jackson    文件:BeanProcessor.java   
/**
 * <p>processType</p>
 *
 * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object.
 * @param typeOracle a {@link com.github.nmorel.gwtjackson.rebind.JacksonTypeOracle} object.
 * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object.
 * @param typeOracle a {@link com.github.nmorel.gwtjackson.rebind.JacksonTypeOracle} object.
 * @param type a {@link com.google.gwt.core.ext.typeinfo.JClassType} object.
 * @param jsonTypeInfo a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
 * @param propertySubTypes a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
 * @return a {@link com.google.gwt.thirdparty.guava.common.base.Optional} object.
 * @throws com.google.gwt.core.ext.UnableToCompleteException if any.
 */
public static Optional<BeanTypeInfo> processType( TreeLogger logger, JacksonTypeOracle typeOracle, RebindConfiguration configuration,
                                                  JClassType type, Optional<JsonTypeInfo> jsonTypeInfo, Optional<JsonSubTypes>
        propertySubTypes ) throws UnableToCompleteException {

    if ( !jsonTypeInfo.isPresent() ) {
        jsonTypeInfo = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, type, JsonTypeInfo.class );
        if ( !jsonTypeInfo.isPresent() ) {
            return Optional.absent();
        }
    }

    Id use = jsonTypeInfo.get().use();
    As include = jsonTypeInfo.get().include();
    String propertyName = jsonTypeInfo.get().property().isEmpty() ? jsonTypeInfo.get().use().getDefaultPropertyName() : jsonTypeInfo
            .get().property();

    Optional<JsonSubTypes> typeSubTypes = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, type, JsonSubTypes.class );

    // TODO we could do better, we actually extract metadata twice for a lot of classes
    ImmutableMap<JClassType, String> classToSerializationMetadata = extractMetadata( logger, configuration, type, jsonTypeInfo,
            propertySubTypes, typeSubTypes, CreatorUtils
                    .filterSubtypesForSerialization( logger, configuration, type ) );
    ImmutableMap<JClassType, String> classToDeserializationMetadata = extractMetadata( logger, configuration, type, jsonTypeInfo,
            propertySubTypes, typeSubTypes, CreatorUtils
                    .filterSubtypesForDeserialization( logger, configuration, type ) );

    return Optional.of(
            new BeanTypeInfo( use, include, propertyName, classToSerializationMetadata, classToDeserializationMetadata ) );
}
项目:gwt-jackson    文件:BeanTypeInfo.java   
BeanTypeInfo( Id use, As include, String propertyName, ImmutableMap<JClassType, String> mapTypeToSerializationMetadata,
              ImmutableMap<JClassType, String> mapTypeToDeserializationMetadata ) {
    this.use = use;
    this.include = include;
    this.propertyName = propertyName;
    this.mapTypeToSerializationMetadata = mapTypeToSerializationMetadata;
    this.mapTypeToDeserializationMetadata = mapTypeToDeserializationMetadata;
}
项目:dremio-oss    文件:EnumTypeIdResolver.java   
@Override
public Id getMechanism() {
  return Id.CUSTOM;
}
项目:flowable-engine    文件:SubmitFormRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestFormProperty.class)
public List<RestFormProperty> getProperties() {
    return properties;
}
项目:flowable-engine    文件:ProcessInstanceQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:SignalEventReceivedRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
@ApiModelProperty(value = "Array of variables (in the general variables format) to use as payload to pass along with the signal. Cannot be used in case async is set to true, this will result in an error.")
public List<RestVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:ProcessInstanceCreateRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public List<RestVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:ProcessInstanceCreateRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public List<RestVariable> getTransientVariables() {
    return transientVariables;
}
项目:flowable-engine    文件:ExecutionActionRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public List<RestVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:ExecutionActionRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public List<RestVariable> getTransientVariables() {
    return transientVariables;
}
项目:flowable-engine    文件:ExecutionQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:ExecutionQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public void setProcessInstanceVariables(List<QueryVariable> processInstanceVariables) {
    this.processInstanceVariables = processInstanceVariables;
}
项目:flowable-engine    文件:TaskQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getTaskVariables() {
    return taskVariables;
}
项目:flowable-engine    文件:TaskQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getProcessInstanceVariables() {
    return processInstanceVariables;
}
项目:flowable-engine    文件:TaskActionRequest.java   
@ApiModelProperty(value = "If action is complete, you can use this parameter to set variables ")
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public List<RestVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:TaskActionRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = RestVariable.class)
public void setTransientVariables(List<RestVariable> transientVariables) {
    this.transientVariables = transientVariables;
}
项目:flowable-engine    文件:HistoricVariableInstanceQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getVariables() {
    return variables;
}
项目:flowable-engine    文件:HistoricTaskInstanceQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getTaskVariables() {
    return taskVariables;
}
项目:flowable-engine    文件:HistoricTaskInstanceQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getProcessVariables() {
    return processVariables;
}
项目:flowable-engine    文件:HistoricProcessInstanceQueryRequest.java   
@JsonTypeInfo(use = Id.CLASS, defaultImpl = QueryVariable.class)
public List<QueryVariable> getVariables() {
    return variables;
}
项目:step    文件:ArtefactTypeIdResolver.java   
@Override
public Id getMechanism() {
    return Id.CUSTOM;
}
项目:esBench    文件:FieldMetadataTypeIdResolver.java   
@Override
public Id getMechanism() {
    return JsonTypeInfo.Id.CUSTOM;
}
项目:antioch    文件:SearchResult.java   
@JsonTypeInfo(use = Id.NAME, include = As.EXISTING_PROPERTY)
public AntiochQuery getQuery() {
  return query;
}
项目:kelp-additional-kernels    文件:StructureElementSimilarityTypeResolver.java   
public Id getMechanism() {
    return Id.CUSTOM;
}
项目:presto    文件:AbstractTypedJacksonModule.java   
@Override
public Id getMechanism()
{
    return Id.NAME;
}
项目:logsniffer    文件:ConfiguredBean.java   
@Override
public Id getMechanism() {
    return Id.NAME;
}
项目:QuizUpWinner    文件:TypeNameIdResolver.java   
public JsonTypeInfo.Id getMechanism()
{
  return JsonTypeInfo.Id.NAME;
}
项目:QuizUpWinner    文件:StdTypeResolverBuilder.java   
public static StdTypeResolverBuilder noTypeInfoBuilder()
{
  return new StdTypeResolverBuilder().init(JsonTypeInfo.Id.NONE, null);
}
项目:QuizUpWinner    文件:ClassNameIdResolver.java   
public JsonTypeInfo.Id getMechanism()
{
  return JsonTypeInfo.Id.CLASS;
}
项目:QuizUpWinner    文件:MinimalClassNameIdResolver.java   
public JsonTypeInfo.Id getMechanism()
{
  return JsonTypeInfo.Id.MINIMAL_CLASS;
}
项目:depgraph-maven-plugin    文件:NodeTypeResolver.java   
@Override
public Id getMechanism() {
  return Id.CUSTOM;
}
项目:depgraph-maven-plugin    文件:NodeTypeResolverTest.java   
@Test
public void getMechanism() {
  assertEquals(Id.CUSTOM, this.resolver.getMechanism());
}
项目:dawnsci    文件:RegisteredClassIdResolver.java   
@Override
public Id getMechanism() { return Id.CUSTOM; }
项目:buildhealth    文件:BuildHealthWebServer.java   
@Override
public Id getMechanism() {
    return null;
}
项目:gwt-jackson    文件:BeanTypeInfo.java   
/**
 * <p>Getter for the field <code>use</code>.</p>
 *
 * @return a {@link com.fasterxml.jackson.annotation.JsonTypeInfo.Id} object.
 */
public Id getUse() {
    return use;
}
项目:QuizUpWinner    文件:TypeIdResolver.java   
public abstract JsonTypeInfo.Id getMechanism();
项目:QuizUpWinner    文件:TypeResolverBuilder.java   
public abstract T init(JsonTypeInfo.Id paramId, TypeIdResolver paramTypeIdResolver);