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


Java PropertyNamingStrategy类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.PropertyNamingStrategy的典型用法代码示例。如果您正苦于以下问题:Java PropertyNamingStrategy类的具体用法?Java PropertyNamingStrategy怎么用?Java PropertyNamingStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: insertDataset

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void insertDataset(JsonNode dataset)
  throws Exception {

  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);

  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }


  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.append(record);
  dw.close();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:21,代码来源:DatasetDao.java

示例2: setDatasetRecord

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void setDatasetRecord (JsonNode dataset) throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);

  if (record != null) {
    Map<String, Object> params = new HashMap<>();
    params.put("urn", record.getUrn());
    if (record.getUrn().indexOf(":///") == -1) {
      throw new Exception("improperly formatted urn: " + record.getUrn() + ", requires ':///'");
    }
    try {
      Map<String, Object> result = JdbcUtil.wherehowsNamedJdbcTemplate.queryForMap(GET_DATASET_BY_URN, params);
      updateDataset(dataset);
    } catch (EmptyResultDataAccessException e) {
      insertDataset(dataset);
    }
  }
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:20,代码来源:DatasetDao.java

示例3: updateDataset

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void updateDataset(JsonNode dataset)
  throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.update(record.toUpdateDatabaseValue(), record.getUrn());
  dw.close();
}
 
开发者ID:SirAeroWN,项目名称:premier-wherehows,代码行数:18,代码来源:DatasetDao.java

示例4: insertDataset

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void insertDataset(JsonNode dataset)
  throws Exception {

  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }


  // Find layout id
  if (record.getSamplePartitionFullPath() != null) {
    PartitionPatternMatcher ppm = new PartitionPatternMatcher(PartitionLayoutDao.getPartitionLayouts());
    record.setPartitionLayoutPatternId(ppm.analyze(record.getSamplePartitionFullPath()));
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.append(record);
  dw.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:26,代码来源:DatasetDao.java

示例5: setDatasetRecord

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void setDatasetRecord (JsonNode dataset)
  throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);

  if (record != null) {
    Map<String, Object> params = new HashMap<>();
    params.put("urn", record.getUrn());
    try {
      Map<String, Object> result = JdbcUtil.wherehowsNamedJdbcTemplate.queryForMap(GET_DATASET_BY_URN, params);
      updateDataset(dataset);
    } catch (EmptyResultDataAccessException e) {
      insertDataset(dataset);
    }
  }
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:18,代码来源:DatasetDao.java

示例6: updateDataset

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static void updateDataset(JsonNode dataset)
  throws Exception {
  ObjectMapper om = new ObjectMapper();
  om.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
  DatasetRecord record = om.convertValue(dataset, DatasetRecord.class);
  if (record.getRefDatasetUrn() != null) {
    Map<String, Object> refDataset = getDatasetByUrn(record.getRefDatasetUrn());
    // Find ref dataset id
    if (refDataset != null) {
      record.setRefDatasetId(((Long) refDataset.get("id")).intValue());
    }
  }
  // Find layout id
  if (record.getSamplePartitionFullPath() != null) {
    PartitionPatternMatcher ppm = new PartitionPatternMatcher(PartitionLayoutDao.getPartitionLayouts());
    record.setPartitionLayoutPatternId(ppm.analyze(record.getSamplePartitionFullPath()));
  }

  DatabaseWriter dw = new DatabaseWriter(JdbcUtil.wherehowsJdbcTemplate, "dict_dataset");
  dw.update(record.toUpdateDatabaseValue(), record.getUrn());
  dw.close();
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:23,代码来源:DatasetDao.java

示例7: load

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
protected void load(final String dataDir, final boolean update) {
    try {
        final File dir = new File("data/fixtures/" + dataDir);
        final File[] files = dir.listFiles((d, name) -> name.endsWith(".json"));

        if (files == null) {
            throw new IOException("No files found in " + dir.getAbsolutePath());
        }

        final ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        for (File jsonFile : files) {
            final T entity = mapper.readValue(jsonFile, entityClass);
            if (update && entity.getId() != null) {
                update(entity);
            } else {
                create(entity);
            }
        }
    } catch (IOException ioex) {
        throw new RuntimeException(ioex);
    }

}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:25,代码来源:Repository.java

示例8: objectMapper

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static ObjectMapper objectMapper() {
    return new ObjectMapper()
            // Property visibility
            .setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS)
            .setDefaultVisibility(JsonAutoDetect.Value.construct(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC))
            .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
            .setSerializationInclusion(JsonInclude.Include.NON_NULL)
            .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true)

            // Property naming and order
            .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE)

            // Customised de/serializers

            // Formats, locals, encoding, binary data
            .setDateFormat(new SimpleDateFormat("MM/dd/yyyy"))
            .setDefaultPrettyPrinter(new DefaultPrettyPrinter())
            .setLocale(Locale.CANADA);
}
 
开发者ID:readlearncode,项目名称:JSON-framework-comparison,代码行数:20,代码来源:RuntimeSampler.java

示例9: createCluster

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public Optional<Cluster> createCluster(String name, String region, Map<String, String> args)
    throws IOException {
  Map<String, String> createOptions = new HashMap<>(args);
  createOptions.put(SpydraArgument.OPTION_REGION, region);
  List<String> command = ImmutableList.of("--format=json", "beta", "dataproc", "clusters", "create", name);
  StringBuilder outputBuilder = new StringBuilder();
  boolean success = ProcessHelper.executeForOutput(
      buildCommand(command, createOptions, Collections.emptyList()),
      outputBuilder);
  String output = outputBuilder.toString();
  if (success) {
    Cluster cluster = JsonHelper.objectMapper()
        .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE)
        .readValue(output, Cluster.class);
    return Optional.of(cluster);
  } else {
    LOGGER.error("Dataproc cluster creation call failed. Command line output:");
    LOGGER.error(output);
    return Optional.empty();
  }
}
 
开发者ID:spotify,项目名称:spydra,代码行数:22,代码来源:GcloudExecutor.java

示例10: createDefaultMapper

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public static ObjectMapper createDefaultMapper() {

		final ObjectMapper mapper = new ObjectMapper();
		mapper.setSerializationInclusion(Include.NON_NULL);
		mapper.configure(SerializationFeature.INDENT_OUTPUT, false);
		mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

		SimpleModule module = new SimpleModule();
		module.addSerializer(Transaction.class, new TransactionSerializer());
		module.addDeserializer(Transaction.class, new TransactionDeserializer());
		module.addSerializer(Difficulty.class, new DifficultySerializer());
		module.addDeserializer(Difficulty.class, new DifficultyDeserializer());
		module.addSerializer(Block.class, new BlockSerializer());
		module.addDeserializer(Block.class, new BlockDeserializer());
		mapper.registerModule(module);

		return mapper;

	}
 
开发者ID:EonTechnology,项目名称:server,代码行数:21,代码来源:ObjectMapperProvider.java

示例11: fieldNamingStrategySerialize

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
@Test
public void fieldNamingStrategySerialize() throws IOException {
	final ObjectMapper mapper = new VPackMapper();
	mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
		private static final long serialVersionUID = 1L;

		@Override
		public String nameForGetterMethod(
			final MapperConfig<?> config,
			final AnnotatedMethod method,
			final String defaultName) {
			return "bla";
		}
	});
	final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityA()));
	assertThat(vpack, is(notNullValue()));
	assertThat(vpack.isObject(), is(true));
	final VPackSlice bla = vpack.get("bla");
	assertThat(bla.isString(), is(true));
	assertThat(bla.getAsString(), is("a"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:22,代码来源:VPackSerializeDeserializeTest.java

示例12: fieldNamingStrategyDeserialize

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
@Test
public void fieldNamingStrategyDeserialize() throws IOException {
	final VPackBuilder builder = new VPackBuilder();
	builder.add(ValueType.OBJECT);
	builder.add("bla", "test");
	builder.close();
	final ObjectMapper mapper = new VPackMapper();
	mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
		private static final long serialVersionUID = 1L;

		@Override
		public String nameForSetterMethod(
			final MapperConfig<?> config,
			final AnnotatedMethod method,
			final String defaultName) {
			return "bla";
		}
	});
	final TestEntityA entity = mapper.readValue(builder.slice().getBuffer(), TestEntityA.class);
	assertThat(entity, is(notNullValue()));
	assertThat(entity.a, is("test"));
}
 
开发者ID:arangodb,项目名称:jackson-dataformat-velocypack,代码行数:23,代码来源:VPackSerializeDeserializeTest.java

示例13: newInstance

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
/**
 * Creates properly configured Jackson XML Mapper instances.
 * @return XmlMapper instance.
 */
public static XmlMapper newInstance() {
    // Create new mapper
    final JacksonXmlModule module = new JacksonXmlModule();
    module.setDefaultUseWrapper(false);
    XmlMapper mapper = new XmlMapper(module);

    // Configure it
    mapper
        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
        .setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
        .registerModule(new JodaModule())
        .setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));

    return mapper;
}
 
开发者ID:Crim,项目名称:pardot-java-client,代码行数:20,代码来源:JacksonFactory.java

示例14: provideObjectMapper

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public ObjectMapper provideObjectMapper() {
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
  objectMapper.setSerializationInclusion(Include.NON_NULL);
  objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
  objectMapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);

  objectMapper.setDateFormat(provideDateFormat());

  return objectMapper;
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:14,代码来源:RetrofitModule.java

示例15: decryptUserInfo

import com.fasterxml.jackson.databind.PropertyNamingStrategy; //导入依赖的package包/类
public WxAppUserInfoRes decryptUserInfo(String encryptedData, String iv, String sessionKey) {
    byte[] res = WechatAESUtils.decrypt(Base64.decodeBase64(encryptedData),
            Base64.decodeBase64(sessionKey), Base64.decodeBase64(iv));
    if (null != res && res.length > 0) {
        try {
            String resStr = new String(res, "UTF8");
            return getObjectMapper()
                    .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE)
                    .readValue(resStr, WxAppUserInfoRes.class);
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }
    return null;
}
 
开发者ID:superkoh,项目名称:k-framework,代码行数:17,代码来源:WxAppApi.java


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