本文整理汇总了Java中com.fasterxml.jackson.databind.ObjectMapper.registerSubtypes方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.registerSubtypes方法的具体用法?Java ObjectMapper.registerSubtypes怎么用?Java ObjectMapper.registerSubtypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.ObjectMapper
的用法示例。
在下文中一共展示了ObjectMapper.registerSubtypes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createObjectMapper
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectMapper createObjectMapper() {
final YAMLFactory yamlFactory = new YAMLFactory()
.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);
ObjectMapper mapper = new ObjectMapper(yamlFactory)
.registerModule(new Jdk8Module())
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
.enable(SerializationFeature.INDENT_OUTPUT)
.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
}
return mapper;
}
示例2: createObjectMapper
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public static ObjectMapper createObjectMapper() {
final YAMLFactory yamlFactory = new YAMLFactory()
.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);
ObjectMapper mapper = new ObjectMapper(yamlFactory)
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
.enable(SerializationFeature.INDENT_OUTPUT)
.disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
}
return mapper;
}
示例3: extendMapper
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public void extendMapper(ObjectMapper mapper)
{
List<AttachmentSerializer> serializers = tracker.getBeanList();
for( AttachmentSerializer attachmentSerializer : serializers )
{
Map<String, Class<? extends EquellaAttachmentBean>> types = attachmentSerializer.getAttachmentBeanTypes();
if( types != null )
{
for( Entry<String, Class<? extends EquellaAttachmentBean>> entry : types.entrySet() )
{
mapper.registerSubtypes(new NamedType(entry.getValue(), entry.getKey()));
}
}
}
}
示例4: PhysicalPlanReader
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public PhysicalPlanReader(DrillConfig config, ObjectMapper mapper, final DrillbitEndpoint endpoint,
final StoragePluginRegistry pluginRegistry) {
// Endpoint serializer/deserializer.
SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule") //
.addSerializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.Se()) //
.addDeserializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.De()) //
.addSerializer(MajorType.class, new MajorTypeSerDe.Se())
.addDeserializer(MajorType.class, new MajorTypeSerDe.De());
mapper.registerModule(deserModule);
mapper.registerSubtypes(PhysicalOperatorUtil.getSubTypes(config));
InjectableValues injectables = new InjectableValues.Std() //
.addValue(StoragePluginRegistry.class, pluginRegistry) //
.addValue(DrillbitEndpoint.class, endpoint); //
this.mapper = mapper;
this.physicalPlanReader = mapper.reader(PhysicalPlan.class).with(injectables);
this.operatorReader = mapper.reader(PhysicalOperator.class).with(injectables);
this.logicalPlanReader = mapper.reader(LogicalPlan.class).with(injectables);
}
示例5: extendMapper
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@Override
public void extendMapper(ObjectMapper mapper)
{
mapper.registerSubtypes(new NamedType(RootFolderBean.class, RootFolderBean.TYPE));
mapper.registerSubtypes(new NamedType(FolderBean.class, FolderBean.TYPE));
mapper.registerSubtypes(new NamedType(FileBean.class, FileBean.TYPE));
mapper.registerSubtypes(new NamedType(GenericFileBean.class, GenericFileBean.TYPE));
}
示例6: DrillConfig
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
@VisibleForTesting
public DrillConfig(Config config, boolean enableServerConfigs) {
super(config);
logger.debug("Setting up DrillConfig object.");
logger.trace("Given Config object is:\n{}",
config.root().render(ConfigRenderOptions.defaults()));
mapper = new ObjectMapper();
if (enableServerConfigs) {
SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
.addDeserializer(LogicalExpression.class, new LogicalExpression.De(this))
.addDeserializer(SchemaPath.class, new SchemaPath.De());
mapper.registerModule(deserModule);
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
mapper.configure(Feature.ALLOW_COMMENTS, true);
mapper.registerSubtypes(LogicalOperatorBase.getSubTypes(this));
mapper.registerSubtypes(StoragePluginConfigBase.getSubTypes(this));
mapper.registerSubtypes(FormatPluginConfigBase.getSubTypes(this));
}
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
this.startupArguments = ImmutableList.copyOf(bean.getInputArguments());
logger.debug("DrillConfig object initialized.");
}
示例7: PhysicalPlanReader
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
public PhysicalPlanReader(SabotConfig config, ScanResult scanResult, LogicalPlanPersistence lpPersistance, final NodeEndpoint endpoint,
final StoragePluginRegistry pluginRegistry, SabotContext context) {
this.lpPersistance = lpPersistance;
// Endpoint serializer/deserializer.
final SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule")
.addSerializer(NodeEndpoint.class, new NodeEndpointSerDe.Se())
.addDeserializer(NodeEndpoint.class, new NodeEndpointSerDe.De())
.addSerializer(MajorType.class, new MajorTypeSerDe.Se())
.addSerializer(ByteString.class, new ByteStringSer())
.addDeserializer(ByteString.class, new ByteStringDeser())
.addDeserializer(MajorType.class, new MajorTypeSerDe.De());
final ObjectMapper lpMapper = lpPersistance.getMapper();
lpMapper.registerModule(deserModule);
Set<Class<? extends PhysicalOperator>> subTypes = PhysicalOperatorUtil.getSubTypes(scanResult);
for (Class<? extends PhysicalOperator> subType : subTypes) {
lpMapper.registerSubtypes(subType);
}
final InjectableValues injectables = new InjectableValues.Std()
.addValue(StoragePluginRegistry.class, pluginRegistry)
.addValue(SabotContext.class, context)
.addValue(NodeEndpoint.class, endpoint);
this.mapper = lpMapper;
this.physicalPlanReader = mapper.readerFor(PhysicalPlan.class).with(injectables);
this.optionListReader = mapper.readerFor(OptionList.class).with(injectables);
this.operatorReader = mapper.readerFor(PhysicalOperator.class).with(injectables);
}
示例8: registerSubtypes
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static void registerSubtypes(ObjectMapper objectMapper, List<NamedType> subtypes) {
objectMapper.registerSubtypes(subtypes.toArray(new NamedType[]{}));
}
示例9: registerSubtypes
import com.fasterxml.jackson.databind.ObjectMapper; //导入方法依赖的package包/类
private static <T> void registerSubtypes(ObjectMapper mapper, Set<Class<? extends T>> types) {
for (Class<? extends T> type : types) {
mapper.registerSubtypes(type);
}
}