當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleModule.addKeyDeserializer方法代碼示例

本文整理匯總了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);
}
 
開發者ID:luminis-ams,項目名稱:elastic-rest-spring-wrapper,代碼行數:22,代碼來源:RestClientConfig.java

示例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);
}
 
開發者ID:deib-polimi,項目名稱:diceH2020-space4clouds_shared,代碼行數:23,代碼來源:Test2.java

示例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;
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:11,代碼來源:GenericJacksonSegmentInputFormat.java

示例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;
}
 
開發者ID:gchq,項目名稱:koryphe,代碼行數:9,代碼來源:SimpleClassSerializer.java

示例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);
}
 
開發者ID:Sugarya,項目名稱:JSONParserMapTest,代碼行數:8,代碼來源:JacksonParser.java

示例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);
}
 
開發者ID:Turakar,項目名稱:signal4j,代碼行數:15,代碼來源:JsonSignalStore.java

示例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;
}
 
開發者ID:deib-polimi,項目名稱:diceH2020-space4cloudsWS,代碼行數:7,代碼來源:Configurator.java

示例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);
  }
}
 
開發者ID:axbaretto,項目名稱:drill,代碼行數:77,代碼來源:Metadata.java


注:本文中的com.fasterxml.jackson.databind.module.SimpleModule.addKeyDeserializer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。