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


Java JsonTypeName.value方法代码示例

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


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

示例1: FormatPluginOptionsDescriptor

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
/**
 * Uses reflection to extract options based on the fields of the provided config class
 * ("List extensions" field is ignored, pending removal, Char is turned into String)
 * The class must be annotated with {@code @JsonTypeName("type name")}
 * @param pluginConfigClass the config class we want to extract options from through reflection
 */
FormatPluginOptionsDescriptor(Class<? extends FormatPluginConfig> pluginConfigClass) {
  this.pluginConfigClass = pluginConfigClass;
  Map<String, TableParamDef> paramsByName = new LinkedHashMap<>();
  Field[] fields = pluginConfigClass.getDeclaredFields();
  // @JsonTypeName("text")
  JsonTypeName annotation = pluginConfigClass.getAnnotation(JsonTypeName.class);
  this.typeName = annotation != null ? annotation.value() : null;
  if (this.typeName != null) {
    paramsByName.put("type", new TableParamDef("type", String.class));
  }
  for (Field field : fields) {
    if (Modifier.isStatic(field.getModifiers())
        // we want to deprecate this field
        || (field.getName().equals("extensions") && field.getType() == List.class)) {
      continue;
    }
    Class<?> fieldType = field.getType();
    if (fieldType == char.class) {
      // calcite does not like char type. Just use String and enforce later that length == 1
      fieldType = String.class;
    }
    paramsByName.put(field.getName(), new TableParamDef(field.getName(), fieldType).optional());
  }
  this.functionParamsByName = unmodifiableMap(paramsByName);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:FormatPluginOptionsDescriptor.java

示例2: init

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
public void init(JavaType baseType) {
    this.baseType = baseType;
    ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
    classes.add(baseType.getRawClass());
    classes.addAll(Arrays.asList(DtoModules.extensionClasses()));
    for ( Class<?> c : classes) {
        if( baseType.getRawClass().isAssignableFrom(c) ) {
            JsonTypeName jsonAnnoation = c.getAnnotation(JsonTypeName.class);
            if(jsonAnnoation!=null && jsonAnnoation.value()!=null) {
                typeToId.put(c, jsonAnnoation.value());
                idToType.put(jsonAnnoation.value(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
            } else {
                XmlRootElement xmlAnnoation = c.getAnnotation(XmlRootElement.class);
                if(xmlAnnoation!=null && xmlAnnoation.name()!=null) {
                    typeToId.put(c, xmlAnnoation.name());
                    idToType.put(xmlAnnoation.name(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                    idToType.put(c.getName(), TypeFactory.defaultInstance().constructSpecializedType(baseType, c));
                }
            }
        }
    }
}
 
开发者ID:christian-posta,项目名称:activemq-apollo-java-port,代码行数:24,代码来源:ApolloTypeIdResolver.java

示例3: runnerFor

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
@Override
public <J> Runnable runnerFor(J job) {
   Assert.notNull(job, "Pre-condition violated: job != null.");

   JsonTypeName type = job.getClass().getAnnotation(JsonTypeName.class);
   Assert.notNull(type, "Pre-condition violated: Job has a @JsonTypeName.");
   String jsonType = type.value();
   if (!StringUtils.hasLength(jsonType)) {
      // If the type is not specified in the annotation, use the simple class name as documented.
      jsonType = job.getClass().getSimpleName();
   }

   // Check for bean existence and that bean is a prototype.
   // Beans have to be prototypes, because they are configured with the job vars below.
   if (!applicationContext.isPrototype(jsonType)) {
      throw new IllegalArgumentException(String.format(
            "Job runners have to be prototypes, but job runner %s is none.", jsonType));
   }

   Object runner = applicationContext.getBean(jsonType, job);
   if (!(runner instanceof Runnable)) {
      throw new IllegalArgumentException(String.format(
            "Job runners need to be Runnable, but job runner %s (%s) is not.",
            jsonType, runner.getClass().getName()));
   }

   return (Runnable) runner;
}
 
开发者ID:shopping24,项目名称:redjob,代码行数:29,代码来源:JsonTypeJobRunnerFactory.java

示例4: getStructureElementIdentifier

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
/**
 * Returns the identifier of a given class
 * 
 * @param c
 *            the class whose identifier is requested
 * @return the class identifier
 */
public static String getStructureElementIdentifier(
		Class<? extends StructureElement> c) {
	String structureElementAbbreviation;
	if (c.isAnnotationPresent(JsonTypeName.class)) {
		JsonTypeName info = c.getAnnotation(JsonTypeName.class);
		structureElementAbbreviation = info.value();

	} else {
		structureElementAbbreviation = c.getSimpleName().toUpperCase();
	}
	return structureElementAbbreviation;
}
 
开发者ID:SAG-KeLP,项目名称:kelp-additional-kernels,代码行数:20,代码来源:StructureElementFactory.java

示例5: extractTypeLabel

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
protected String extractTypeLabel(Class<?> type) {
    // TODO: get rid of Jackson annotations dependency .. devise our own that reflect Bootique style of config factory
    // subclassing...

    JsonTypeName typeName = type.getAnnotation(JsonTypeName.class);
    return typeName != null ? typeName.value() : null;
}
 
开发者ID:bootique,项目名称:bootique,代码行数:8,代码来源:ConfigMetadataCompiler.java

示例6: buildTypeId

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
private <T extends Filter> String buildTypeId(final String id, final Class<T> type) {
    final JsonTypeName annotation = type.getAnnotation(JsonTypeName.class);

    if (annotation == null) {
        return id;
    }

    return annotation.value();
}
 
开发者ID:spotify,项目名称:heroic,代码行数:10,代码来源:FilterRegistry.java

示例7: getTypeLabel

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
private String getTypeLabel(Class<? extends ManagedDataSourceFactory> factoryType) {

        // TODO: see TODO in ConfigMetadataCompiler ... at least maybe create a public API for this in Bootique to
        // avoid parsing annotations inside the modules...
        JsonTypeName typeName = factoryType.getAnnotation(JsonTypeName.class);

        if (typeName == null) {
            throw new BootiqueException(1, "Invalid ManagedDataSourceFactory:  "
                    + factoryType.getName()
                    + ". Not annotated with @JsonTypeName.");
        }

        return typeName.value();
    }
 
开发者ID:bootique,项目名称:bootique-jdbc,代码行数:15,代码来源:ManagedDataSourceFactoryProxy.java

示例8: findTypeName

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
public String findTypeName(AnnotatedClass paramAnnotatedClass)
{
  JsonTypeName localJsonTypeName = (JsonTypeName)paramAnnotatedClass.getAnnotation(JsonTypeName.class);
  if (localJsonTypeName == null)
    return null;
  return localJsonTypeName.value();
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:8,代码来源:JacksonAnnotationIntrospector.java

示例9: getTypeName

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
private String getTypeName(JsonTypeInfo parentJsonTypeInfo, final Class<?> cls) {
    // Id.CLASS
    if (parentJsonTypeInfo.use() == JsonTypeInfo.Id.CLASS) {
        return cls.getName();
    }
    // find @JsonTypeName recursively
    final JsonTypeName jsonTypeName = getAnnotationRecursive(cls, JsonTypeName.class);
    if (jsonTypeName != null && !jsonTypeName.value().isEmpty()) {
        return jsonTypeName.value();
    }
    // find @JsonSubTypes.Type recursively
    final JsonSubTypes jsonSubTypes = getAnnotationRecursive(cls, JsonSubTypes.class, new Predicate<JsonSubTypes>() {
        @Override
        public boolean test(JsonSubTypes types) {
            return getJsonSubTypeForClass(types, cls) != null;
        }
    });
    if (jsonSubTypes != null) {
        final JsonSubTypes.Type jsonSubType = getJsonSubTypeForClass(jsonSubTypes, cls);
        if (!jsonSubType.name().isEmpty()) {
            return jsonSubType.name();
        }
    }
    // use simplified class name if it's not an interface or abstract
    if(!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) {
        return cls.getName().substring(cls.getName().lastIndexOf(".") + 1);
    }
    return null;
}
 
开发者ID:vojtechhabarta,项目名称:typescript-generator,代码行数:30,代码来源:Jackson2Parser.java

示例10: getName

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的package包/类
public String getName(JavaType type) {
	Class<?> rawClass = type.getRawClass();
	JsonTypeName typeName = rawClass.getAnnotation(JsonTypeName.class);
	if (typeName != null) {
		return typeName.value();
	}
	else {
		return getName(rawClass);
	}
}
 
开发者ID:raphaeljolivet,项目名称:java2typescript,代码行数:11,代码来源:SimpleJacksonTSTypeNamingStrategy.java

示例11: getInheritance

import com.fasterxml.jackson.annotation.JsonTypeName; //导入方法依赖的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


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