本文整理汇总了Java中com.fasterxml.jackson.databind.module.SimpleModule.addKeyDeserializer方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleModule.addKeyDeserializer方法的具体用法?Java SimpleModule.addKeyDeserializer怎么用?Java SimpleModule.addKeyDeserializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.module.SimpleModule
的用法示例。
在下文中一共展示了SimpleModule.addKeyDeserializer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configObjectMapper
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
@Autowired
public void configObjectMapper(ObjectMapper objectMapper) {
AggregationDeserializer deserializer = new AggregationDeserializer();
deserializer.register("sterms", TermsAggregation.class);
deserializer.register("histogram", HistogramAggregation.class);
deserializer.register("date_histogram", DateHistogramAggregation.class);
deserializer.register("avg", SingleValueMetricsAggregation.class);
deserializer.register("sum", SingleValueMetricsAggregation.class);
deserializer.register("max", SingleValueMetricsAggregation.class);
deserializer.register("min", SingleValueMetricsAggregation.class);
deserializer.register("cardinality", SingleValueMetricsAggregation.class);
deserializer.register("value_count", SingleValueMetricsAggregation.class);
SimpleModule module = new SimpleModule("AggregationDeserializer",
new Version(1, 0, 0, null, "eu.luminis.elastic", "aggregation-elastic"));
module.addDeserializer(Aggregation.class, deserializer);
module.addKeyDeserializer(String.class, new AggregationKeyDeserializer());
objectMapper.registerModule(module);
}
示例2: test1
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
@Test
public void test1() {
InstanceData_old data = InstanceDataGenerator_old.build();
System.out.println(data.toString());
try {
ObjectMapper mapper = new ObjectMapper().registerModule(new Jdk8Module());
SimpleModule module = new SimpleModule();
module.addKeyDeserializer(TypeVMJobClassKey.class, TypeVMJobClassKey.getDeserializer() );
mapper.registerModule(module);
String serialized = mapper.writeValueAsString(data);
System.out.println(serialized);
InstanceData_old data2 = mapper.readValue(serialized, InstanceData_old.class);
System.out.println(data2.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(data.getGamma() ==240);
}
示例3: getAndRegisterDeserializers
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
protected ISegmentAdapter<IBaseSegmentDTO, T> getAndRegisterDeserializers(String segmentType) throws NoSegmentAdapterFoundException {
ISegmentAdapter<IBaseSegmentDTO, T> adapter = adapterRegistry.getAdapterForType(segmentType);
//Create custom deserializer for XInfos
SimpleModule module = new SimpleModule();
module.addDeserializer(IConnectionXInfoDTO.class, new ConnectionXInfoDeserializer(adapter));
module.addKeyDeserializer(String.class, new XInfoKeyDeserializer());
module.addDeserializer(ISegmentXInfoDTO.class, new SegmentXInfoDeserializer(adapter));
jsonFactory.getCodec().registerModule(module);
return adapter;
}
示例4: getModule
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
public static SimpleModule getModule() {
final SimpleModule module = new SimpleModule();
module.addSerializer(Class.class, (JsonSerializer) new SimpleClassSerializer());
module.addDeserializer(Class.class, new SimpleClassDeserializer());
module.addKeySerializer(Class.class, (JsonSerializer) new SimpleClassKeySerializer());
module.addKeyDeserializer(Class.class, new SimpleClassKeyDeserializer());
return module;
}
示例5: JacksonParser
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
public JacksonParser() {
mObjectMapper = new ObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addKeyDeserializer(CategoryEntity.class, new MapKeyDeserializer());
simpleModule.addKeySerializer(CategoryEntity.class, new MapKeySerializer(CategoryEntity.class));
mObjectMapper.registerModule(simpleModule);
}
示例6: load
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
public static JsonSignalStore load(File file) throws IOException {
SimpleModule module = new SimpleModule();
module.addDeserializer(IdentityKeyPair.class, new IdentityKeyPairDeserializer());
module.addDeserializer(IdentityKey.class, new IdentityKeyDeserializer());
module.addDeserializer(PreKeyRecord.class, new PreKeyRecordDeserializer());
module.addDeserializer(SignedPreKeyRecord.class, new SignedPreKeyRecordDeserializer());
module.addDeserializer(SessionRecord.class, new SessionRecordDeserializer());
module.addDeserializer(GroupId.class, new GroupIdDeserializer());
module.addKeyDeserializer(SignalProtocolAddress.class, new SignalProtocolAddressDeserializer());
module.addKeyDeserializer(GroupId.class, new GroupIdKeyDeserializer());
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(module);
return mapper.readValue(file, JsonSignalStore.class);
}
示例7: customModule
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
@Bean
public SimpleModule customModule() {
SimpleModule module = new SimpleModule();
module.addKeyDeserializer(TypeVMJobClassKey.class, TypeVMJobClassKey.getDeserializer());
return module;
}
示例8: readBlockMeta
import com.fasterxml.jackson.databind.module.SimpleModule; //导入方法依赖的package包/类
/**
* Read the parquet metadata from a file
*
* @param path to metadata file
* @param dirsOnly true for {@link Metadata#METADATA_DIRECTORIES_FILENAME}
* or false for {@link Metadata#METADATA_FILENAME} files reading
* @param metaContext current metadata context
* @throws IOException if metadata file can't be read or updated
*/
private void readBlockMeta(Path path, boolean dirsOnly, MetadataContext metaContext) {
Stopwatch timer = Stopwatch.createStarted();
Path metadataParentDir = Path.getPathWithoutSchemeAndAuthority(path.getParent());
String metadataParentDirPath = metadataParentDir.toUri().getPath();
ObjectMapper mapper = new ObjectMapper();
final SimpleModule serialModule = new SimpleModule();
serialModule.addDeserializer(SchemaPath.class, new SchemaPath.De());
serialModule.addKeyDeserializer(ColumnTypeMetadata_v2.Key.class, new ColumnTypeMetadata_v2.Key.DeSerializer());
serialModule.addKeyDeserializer(ColumnTypeMetadata_v3.Key.class, new ColumnTypeMetadata_v3.Key.DeSerializer());
AfterburnerModule module = new AfterburnerModule();
module.setUseOptimizedBeanDeserializer(true);
mapper.registerModule(serialModule);
mapper.registerModule(module);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try (FSDataInputStream is = fs.open(path)) {
boolean alreadyCheckedModification = false;
boolean newMetadata = false;
alreadyCheckedModification = metaContext.getStatus(metadataParentDirPath);
if (dirsOnly) {
parquetTableMetadataDirs = mapper.readValue(is, ParquetTableMetadataDirs.class);
logger.info("Took {} ms to read directories from directory cache file", timer.elapsed(TimeUnit.MILLISECONDS));
timer.stop();
parquetTableMetadataDirs.updateRelativePaths(metadataParentDirPath);
if (!alreadyCheckedModification && tableModified(parquetTableMetadataDirs.getDirectories(), path, metadataParentDir, metaContext)) {
parquetTableMetadataDirs =
(createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(path.getParent()).toString())).getRight();
newMetadata = true;
}
} else {
parquetTableMetadata = mapper.readValue(is, ParquetTableMetadataBase.class);
logger.info("Took {} ms to read metadata from cache file", timer.elapsed(TimeUnit.MILLISECONDS));
timer.stop();
if (new MetadataVersion(parquetTableMetadata.getMetadataVersion()).compareTo(new MetadataVersion(3, 0)) >= 0) {
((ParquetTableMetadata_v3) parquetTableMetadata).updateRelativePaths(metadataParentDirPath);
}
if (!alreadyCheckedModification && tableModified(parquetTableMetadata.getDirectories(), path, metadataParentDir, metaContext)) {
parquetTableMetadata =
(createMetaFilesRecursively(Path.getPathWithoutSchemeAndAuthority(path.getParent()).toString())).getLeft();
newMetadata = true;
}
// DRILL-5009: Remove the RowGroup if it is empty
List<? extends ParquetFileMetadata> files = parquetTableMetadata.getFiles();
for (ParquetFileMetadata file : files) {
List<? extends RowGroupMetadata> rowGroups = file.getRowGroups();
for (Iterator<? extends RowGroupMetadata> iter = rowGroups.iterator(); iter.hasNext(); ) {
RowGroupMetadata r = iter.next();
if (r.getRowCount() == 0) {
iter.remove();
}
}
}
}
if (newMetadata) {
// if new metadata files were created, invalidate the existing metadata context
metaContext.clear();
}
} catch (IOException e) {
logger.error("Failed to read '{}' metadata file", path, e);
metaContext.setMetadataCacheCorrupted(true);
}
}