com.fasterxml.jackson.databind.ser.SerializerFactory#com.fasterxml.jackson.databind.ser.DefaultSerializerProvider源码实例Demo

下面列出了com.fasterxml.jackson.databind.ser.SerializerFactory#com.fasterxml.jackson.databind.ser.DefaultSerializerProvider 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lams   文件: SequenceWriter.java
public SequenceWriter(DefaultSerializerProvider prov, JsonGenerator gen,
        boolean closeGenerator, ObjectWriter.Prefetch prefetch)
    throws IOException
{
    _provider = prov;
    _generator = gen;
    _closeGenerator = closeGenerator;
    _rootSerializer = prefetch.getValueSerializer();
    _typeSerializer = prefetch.getTypeSerializer();

    _config = prov.getConfig();
    _cfgFlush = _config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE);
    _cfgCloseCloseable = _config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE);
    // important: need to cache "root value" serializers, to handle polymorphic
    // types properly
    _dynamicSerializers = PropertySerializerMap.emptyForRootValues();
}
 
源代码2 项目: typescript-generator   文件: Jackson2Parser.java
private BeanHelper getBeanHelper(Class<?> beanClass) {
    if (beanClass == null) {
        return null;
    }
    if (beanClass == Enum.class) {
        return null;
    }
    try {
        final DefaultSerializerProvider.Impl serializerProvider1 = (DefaultSerializerProvider.Impl) objectMapper.getSerializerProvider();
        final DefaultSerializerProvider.Impl serializerProvider2 = serializerProvider1.createInstance(objectMapper.getSerializationConfig(), objectMapper.getSerializerFactory());
        final JavaType simpleType = objectMapper.constructType(beanClass);
        final JsonSerializer<?> jsonSerializer = BeanSerializerFactory.instance.createSerializer(serializerProvider2, simpleType);
        if (jsonSerializer == null) {
            return null;
        }
        if (jsonSerializer instanceof BeanSerializer) {
            return new BeanHelper((BeanSerializer) jsonSerializer);
        } else {
            return null;
        }
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    }
}
 
源代码3 项目: pinpoint   文件: ObjectMapperIT.java
@Test
public void testConstructor() throws Exception {
    ObjectMapper mapper1 = new ObjectMapper();
    ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());

    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();

    Constructor<?> omConstructor = ObjectMapper.class.getConstructor(JsonFactory.class, DefaultSerializerProvider.class, DefaultDeserializationContext.class);
    Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
    Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor1));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor2));

    verifier.verifyTraceCount(0);
}
 
源代码4 项目: pinpoint   文件: ObjectMapperJDK7IT.java
@Test
public void testConstructor() throws Exception {
    ObjectMapper mapper1 = new ObjectMapper();
    ObjectMapper mapper2 = new ObjectMapper(new JsonFactory());

    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();

    Constructor<?> omConstructor = ObjectMapper.class.getConstructor(JsonFactory.class, DefaultSerializerProvider.class, DefaultDeserializationContext.class);
    Constructor<?> omConstructor1 = ObjectMapper.class.getConstructor();
    Constructor<?> omConstructor2 = ObjectMapper.class.getConstructor(JsonFactory.class);
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor1));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor));
    verifier.verifyTrace(event(SERVICE_TYPE, omConstructor2));

    verifier.verifyTraceCount(0);
}
 
源代码5 项目: rapidoid   文件: JSON.java
public static synchronized void reset() {
	for (ObjectMapper mapper : U.list(MAPPER, PRETTY_MAPPER)) {

		SerializerProvider serializerProvider = mapper.getSerializerProvider();

		if (serializerProvider instanceof DefaultSerializerProvider) {
			DefaultSerializerProvider provider = (DefaultSerializerProvider) serializerProvider;
			provider.flushCachedSerializers();
		} else {
			Log.warn("Couldn't clear the cache of Jackson serializers!", "class", Cls.of(serializerProvider));
		}

		DeserializationContext deserializationContext = mapper.getDeserializationContext();
		Object cache = Cls.getFieldValue(deserializationContext, "_cache");

		if (cache instanceof DeserializerCache) {
			DeserializerCache deserializerCache = (DeserializerCache) cache;
			deserializerCache.flushCachedDeserializers();
		} else {
			Log.warn("Couldn't clear the cache of Jackson deserializers!", "class", Cls.of(cache));
		}
	}
}
 
源代码6 项目: beakerx   文件: ConstantBandSerializerTest.java
@Test
public void serializeBigIntXWithNanoPlotType_resultJsonHasStringXs() throws IOException {
  //when
  ConstantBand constantBand = new ConstantBand();
  constantBand.setX(
      Arrays.asList(
          new BigInteger("12345678901234567891000"), new BigInteger("12345678901234567892000")));
  constantBand.setPlotType(NanoPlot.class);
  constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("x")).isTrue();
  ArrayNode arrayNode = (ArrayNode) actualObj.get("x");
  Assertions.assertThat(arrayNode.get(0).isTextual()).isTrue();
}
 
源代码7 项目: beakerx   文件: LineSerializerTest.java
@Test
public void serializeWidthLine_resultJsonHasWidth() throws IOException {
  //when
  line.setWidth(1f);
  lineSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("width")).isTrue();
  Assertions.assertThat(actualObj.get("width").asDouble()).isEqualTo(1.0);
}
 
源代码8 项目: beakerx   文件: HistogramSerializerTest.java
@Test
public void serializeRangeMaxOfHistogram_resultJsonHasRangeMax() throws IOException {
  //when
  histogram.setRangeMax(11);
  histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("range_max")).isTrue();
  Assertions.assertThat(actualObj.get("range_max").asInt()).isEqualTo(11);
}
 
源代码9 项目: beakerx   文件: LegendPositionSerializerTest.java
@Test
public void serializePositionOfLegendPosition_resultJsonHasPosition() throws IOException {
  //when
  legendPosition.setPosition(LegendPosition.Position.LEFT);
  legendPositionSerializer.serialize(legendPosition, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("position")).isTrue();
  Assertions.assertThat(actualObj.get("position").asText()).isEqualTo("LEFT");
}
 
源代码10 项目: beakerx   文件: CategoryPointsSerializerTest.java
@Test
public void serializeOutlineColorsCategoryPoints_resultJsonHasOutlineColors() throws IOException {
  //when
  CategoryPoints categoryPoints = new CategoryPoints();
  categoryPoints.setOutlineColor(Arrays.asList(Color.BLUE, Color.GREEN, Color.BLACK));
  categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("outline_colors")).isTrue();
  ArrayNode arrayNode = (ArrayNode) actualObj.get("outline_colors");
  Assertions.assertThat(arrayNode.get(1).get("rgb").asInt()).isEqualTo(Color.GREEN.getRGB());
}
 
源代码11 项目: beakerx   文件: CategoryPlotSerializerTest.java
@Test
public void serializeOrientationCategoryPlot_resultJsonHasOrientation() throws IOException {
  //when
  CategoryPlot categoryPlot = new CategoryPlot();
  categoryPlot.setOrientation(PlotOrientationType.VERTICAL);
  categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("orientation")).isTrue();
  Assertions.assertThat(actualObj.get("orientation").asText()).isEqualTo("VERTICAL");
}
 
源代码12 项目: beakerx   文件: XYChartSerializerTest.java
@Test
public void serializeConstantBandsOfXYChartPlot_resultJsonHasConstantBands() throws IOException {
  //given
  ConstantBand constantBand = new ConstantBand();
  plot.add(constantBand);
  //when
  xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("constant_bands")).isTrue();
  Assertions.assertThat(actualObj.get("constant_bands")).isNotEmpty();
}
 
源代码13 项目: beakerx   文件: XYChartSerializerTest.java
@Test
public void serializeGraphicsOfXYChartPlot_resultJsonHasGraphicsList() throws IOException {
  //given
  Line line = new Line();
  line.setX(Arrays.asList(1, 2, 3));
  line.setY(Arrays.asList(2, 3, 4));
  plot.add(line);
  //when
  xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("graphics_list")).isTrue();
  Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty();
}
 
源代码14 项目: beakerx   文件: YAxisSerializerTest.java
@Test
public void serializeYAxis_resultJsonHasType() throws IOException {
  //when
  yAxisSerializer.serialize(yAxis, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("type")).isTrue();
  Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("YAxis");
}
 
源代码15 项目: beakerx   文件: ConstantLineSerializerTest.java
@Test
public void serializeShowLabelConstantLine_resultJsonHasShowLabel() throws IOException {
  //when
  ConstantLine constantLine = new ConstantLine();
  constantLine.setShowLabel(true);
  constantLineSerializer.serialize(constantLine, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("showLabel")).isTrue();
  Assertions.assertThat(actualObj.get("showLabel").asBoolean()).isTrue();
}
 
源代码16 项目: beakerx   文件: LegendPositionSerializerTest.java
@Test
public void serializeLegendPosition_resultJsonHasType() throws IOException {
  //when
  legendPositionSerializer.serialize(legendPosition, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("type")).isTrue();
  Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("LegendPosition");
}
 
源代码17 项目: beakerx   文件: XYChartSerializerTest.java
@Test
public void serializeXLowerBoundOfXYChartPlot_resultJsonHasXLowerBound() throws IOException {
  //when
  plot.setXBound(0.5, 1.5);
  xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("x_lower_bound")).isTrue();
  Assertions.assertThat(actualObj.get("x_lower_bound").asDouble()).isEqualTo(0.5);
}
 
源代码18 项目: beakerx   文件: XYGraphicsSerializerTest.java
@Test
public void serializeDisplayNameOfXYGraphicsLine_resultJsonHasDisplayName() throws IOException {
  //when
  line.setDisplayName("some display name");
  xyGraphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("display_name")).isTrue();
  Assertions.assertThat(actualObj.get("display_name").asText()).isEqualTo("some display name");
}
 
源代码19 项目: beakerx   文件: CombinedPlotSerializerTest.java
@Test
public void serializeInitWidthOfCombinedPlot_resultJsonHasInitWidth() throws IOException {
  //when
  CombinedPlot combinedPlot = new CombinedPlot();
  combinedPlot.setInitWidth(600);
  combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("init_width")).isTrue();
  Assertions.assertThat(actualObj.get("init_width").asInt()).isEqualTo(600);
}
 
源代码20 项目: beakerx   文件: StemsSerializerTest.java
@Test
public void serializeWidthStems_resultJsonHasWidth() throws IOException {
  //when
  stems.setWidth(11f);
  stemsSerializer.serialize(stems, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("width")).isTrue();
  Assertions.assertThat(actualObj.get("width").asInt()).isEqualTo(11);
}
 
源代码21 项目: beakerx   文件: ConstantBandSerializerTest.java
@Test
public void serializeConstantBand_resultJsonHasType() throws IOException {
  //when
  ConstantBand constantBand = new ConstantBand() {};
  constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("type")).isTrue();
  Assertions.assertThat(actualObj.get("type").asText()).isEqualTo("ConstantBand");
}
 
源代码22 项目: beakerx   文件: HistogramSerializerTest.java
@Test
public void serializeRangeMinOfHistogram_resultJsonHasRangeMin() throws IOException {
  //when
  histogram.setRangeMin(11);
  histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("range_min")).isTrue();
  Assertions.assertThat(actualObj.get("range_min").asInt()).isEqualTo(11);
}
 
源代码23 项目: beakerx   文件: ConstantBandSerializerTest.java
@Test
public void serializeYConstantBand_resultJsonHasY() throws IOException {
  //when
  ConstantBand constantBand = new ConstantBand();
  constantBand.setY(Arrays.asList(1, 2, 3));
  constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("y")).isTrue();
  Assertions.assertThat(actualObj.get("y")).isNotEmpty();
}
 
源代码24 项目: beakerx   文件: XYChartSerializerTest.java
@Test
public void serializeLodThresholdOfXYChartPlot_resultJsonHasLodThreshold() throws IOException {
  //when
  plot.setLodThreshold(11);
  xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("lodThreshold")).isTrue();
  Assertions.assertThat(actualObj.get("lodThreshold").asInt()).isEqualTo(11);
}
 
源代码25 项目: beakerx   文件: ConstantBandSerializerTest.java
@Test
public void serializeYAxisConstantBand_resultJsonHasYAxis() throws IOException {
  //when
  ConstantBand constantBand = new ConstantBand();
  constantBand.setyAxis("Y Axis name");
  constantBandSerializer.serialize(constantBand, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("yAxis")).isTrue();
  Assertions.assertThat(actualObj.get("yAxis").asText()).isEqualTo("Y Axis name");
}
 
源代码26 项目: beakerx   文件: XYChartSerializerTest.java
@Test
public void serializeXLogBaseOfXYChartPlot_resultJsonHasXLogBase() throws IOException {
  //when
  plot.setxLogBase(1.5);
  xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("x_log_base")).isTrue();
  Assertions.assertThat(actualObj.get("x_log_base").asDouble()).isEqualTo(1.5);
}
 
源代码27 项目: beakerx   文件: TreeMapSerializerTest.java
@Test
public void serializeRatioOfTreeMap_resultJsonHasRatio() throws IOException {
  //when
  treeMap.setRatio(2.0);
  treeMapSerializer.serialize(treeMap, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("ratio")).isTrue();
  Assertions.assertThat(actualObj.get("ratio").asDouble()).isEqualTo(2.0);
}
 
源代码28 项目: beakerx   文件: TextSerializerTest.java
@Test
public void serializeColorOfText_resultJsonHasColor() throws IOException {
  //when
  text.setColor(Color.GREEN);
  textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("color")).isTrue();
  Assertions.assertThat(actualObj.get("color").get("rgb").asInt())
      .isEqualTo(Color.GREEN.getRGB());
}
 
源代码29 项目: beakerx   文件: CategoryLinesSerializerTest.java
@Test
public void serializeWidthCategoryLines_resultJsonHasWidth() throws IOException {
  //when
  CategoryLines categoryLines = new CategoryLines();
  categoryLines.setWidth(11f);
  categoryLinesSerializer.serialize(categoryLines, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("width")).isTrue();
  Assertions.assertThat(actualObj.get("width").asInt()).isEqualTo(11);
}
 
源代码30 项目: beakerx   文件: CategoryLinesSerializerTest.java
@Test
public void serializeStrokeTypeStems_resultJsonHasStyle() throws IOException {
  //when
  CategoryLines categoryLines = new CategoryLines();
  categoryLines.setStyle(StrokeType.SOLID);
  categoryLinesSerializer.serialize(categoryLines, jgen, new DefaultSerializerProvider.Impl());
  jgen.flush();
  //then
  JsonNode actualObj = mapper.readTree(sw.toString());
  Assertions.assertThat(actualObj.has("style")).isTrue();
  Assertions.assertThat(actualObj.get("style").asText()).isEqualTo("SOLID");
}