com.fasterxml.jackson.databind.ser.DefaultSerializerProvider Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SequenceWriter.java From lams with GNU General Public License v2.0 | 6 votes |
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(); }
Example #2
Source File: JSON.java From rapidoid with Apache License 2.0 | 6 votes |
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)); } } }
Example #3
Source File: ConstantBandSerializerTest.java From beakerx with Apache License 2.0 | 6 votes |
@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(); }
Example #4
Source File: ObjectMapperJDK7IT.java From pinpoint with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: ObjectMapperIT.java From pinpoint with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: Jackson2Parser.java From typescript-generator with MIT License | 6 votes |
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); } }
Example #7
Source File: TreeMapSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeStickyOfTreeMap_resultJsonHasSticky() throws IOException { //when treeMap.setSticky(true); treeMapSerializer.serialize(treeMap, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("sticky")).isTrue(); Assertions.assertThat(actualObj.get("sticky").asBoolean()).isTrue(); }
Example #8
Source File: PointsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeShapePoints_resultJsonHasShapeSquare() throws IOException { //when points.setShape(ShapeType.SQUARE); pointsSerializer.serialize(points, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("shape")).isTrue(); Assertions.assertThat(actualObj.get("shape").asText()).isEqualTo("rect"); }
Example #9
Source File: CategoryPlotSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeCategoryNamesLabelAngleOfCategoryPlot_resultJsonHasCategoryNamesLabelAngle() throws IOException { //when CategoryPlot categoryPlot = new CategoryPlot(); categoryPlot.setCategoryNamesLabelAngle(0.5); categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("categoryNamesLabelAngle")).isTrue(); Assertions.assertThat(actualObj.get("categoryNamesLabelAngle").asDouble()).isEqualTo(0.5); }
Example #10
Source File: HistogramSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeDataListListOfHistogram_resultJsonHasGraphicsList() throws IOException { //when histogram.setData(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4))); histogramSerializer.serialize(histogram, 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(); }
Example #11
Source File: PointsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeFillPoints_resultJsonHasFill() throws IOException { //when points.setFill(true); pointsSerializer.serialize(points, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("fill")).isTrue(); Assertions.assertThat(actualObj.get("fill").asBoolean()).isTrue(); }
Example #12
Source File: ConstantLineSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeConstantLine_resultJsonHasType() throws IOException { //when ConstantLine constantLine = new ConstantLine() {}; constantLineSerializer.serialize(constantLine, 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("ConstantLine"); }
Example #13
Source File: LineSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeColorLine_resultJsonHasColor() throws IOException { //when line.setColor(Color.GREEN); lineSerializer.serialize(line, 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()); }
Example #14
Source File: TextSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeXText_resultJsonHasX() throws IOException { //when text.setX(new Integer(11)); textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("x")).isTrue(); Assertions.assertThat(actualObj.get("x").asInt()).isEqualTo(11); }
Example #15
Source File: GraphicsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeVisibleLineGraphics_resultJsonHasVisible() throws IOException { //when line.setVisible(true); graphicsSerializer.serialize(line, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("visible")).isTrue(); Assertions.assertThat(actualObj.get("visible").asBoolean()).isTrue(); }
Example #16
Source File: CategoryPointsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeSizeCategoryPoints_resultJsonHasSize() throws IOException { //when CategoryPoints categoryPoints = new CategoryPoints(); categoryPoints.setSize(11); categoryPointsSerializer.serialize(categoryPoints, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("size")).isTrue(); Assertions.assertThat(actualObj.get("size").asInt()).isEqualTo(11); }
Example #17
Source File: TableDisplayAlignmentSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeTableDisplayLeftAligment_resultJsonHasLValue() throws IOException { //when serializer.serialize( TableDisplayAlignmentProvider.LEFT_ALIGNMENT, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); JsonNode actualObj = mapper.readTree(sw.toString()); //then Assertions.assertThat(actualObj.asText()).isEqualTo("L"); }
Example #18
Source File: CategoryStemsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeStrokeTypeCategoryStems_resultJsonHasStyle() throws IOException { //when CategoryStems categoryStems = new CategoryStems(); categoryStems.setStyle(StrokeType.SOLID); categoryStemsSerializer.serialize(categoryStems, 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"); }
Example #19
Source File: CategoryPlotSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeCategoryMarginOfCategoryPlot_resultJsonHasCategoryMargin() throws IOException { //when CategoryPlot categoryPlot = new CategoryPlot(); categoryPlot.setCategoryMargin(0.5); categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("category_margin")).isTrue(); Assertions.assertThat(actualObj.get("category_margin").asDouble()).isEqualTo(0.5); }
Example #20
Source File: LineSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeStrokeTypeLine_resultJsonHasStyle() throws IOException { //when line.setStyle(StrokeType.SOLID); lineSerializer.serialize(line, 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"); }
Example #21
Source File: PointsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeOutlineColorsPoints_resultJsonHasOutlineColors() throws IOException { //when points.setOutlineColor(Arrays.asList(Color.GREEN, Color.BLUE)); pointsSerializer.serialize(points, 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.BLUE.getRGB()); }
Example #22
Source File: AreaSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeColorArea_resultJsonHasColor() throws IOException { //when area.setColor(Color.GREEN); areaSerializer.serialize(area, 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()); }
Example #23
Source File: TextSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializePointerAngleOfText_resultJsonHasPointerAngle() throws IOException { //when text.setPointerAngle(0.5); textSerializer.serialize(text, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("pointer_angle")).isTrue(); Assertions.assertThat(actualObj.get("pointer_angle").asDouble()).isEqualTo(0.5); }
Example #24
Source File: TextSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeText_resultJsonHasType() throws IOException { //when textSerializer.serialize(text, 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("Text"); }
Example #25
Source File: YAxisSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeUpperMarginOfYAxis_resultJsonHasUpperMargin() throws IOException { //when yAxis.setUpperMargin(2.5); yAxisSerializer.serialize(yAxis, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("upper_margin")).isTrue(); Assertions.assertThat(actualObj.get("upper_margin").asDouble()).isEqualTo(2.5); }
Example #26
Source File: BarsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeColorBars_resultJsonHasColor() throws IOException { //when bars.setColor(Color.GREEN); barsSerializer.serialize(bars, 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()); }
Example #27
Source File: StemsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeColorStems_resultJsonHasColor() throws IOException { //when stems.setColor(Color.GREEN); stemsSerializer.serialize(stems, 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()); }
Example #28
Source File: CombinedPlotSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeInitHeightOfCombinedPlot_resultJsonHasInitHeight() throws IOException { //when CombinedPlot combinedPlot = new CombinedPlot(); combinedPlot.setInitHeight(300); combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("init_height")).isTrue(); Assertions.assertThat(actualObj.get("init_height").asInt()).isEqualTo(300); }
Example #29
Source File: HistogramSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeBinCountOfHistogram_resultJsonHasBinCount() throws IOException { //when histogram.setBinCount(11); histogramSerializer.serialize(histogram, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("bin_count")).isTrue(); Assertions.assertThat(actualObj.get("bin_count").asInt()).isEqualTo(11); }
Example #30
Source File: CategoryBarsSerializerTest.java From beakerx with Apache License 2.0 | 5 votes |
@Test public void serializeDrawOutlinesCategoryBars_resultJsonHasDrawOutlines() throws IOException { //when CategoryBars categoryBars = new CategoryBars(); categoryBars.setDrawOutline(Arrays.asList(false, true, false)); categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl()); jgen.flush(); //then JsonNode actualObj = mapper.readTree(sw.toString()); Assertions.assertThat(actualObj.has("outlines")).isTrue(); ArrayNode arrayNode = (ArrayNode) actualObj.get("outlines"); Assertions.assertThat(arrayNode.get(1).asBoolean()).isTrue(); }