com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper.
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: UnwrappingBeanPropertyWriter.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void depositSchemaProperty(final JsonObjectFormatVisitor visitor, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> ser = provider .findValueSerializer(this.getType(), this) .unwrappingSerializer(_nameTransformer); if (ser.isUnwrappingSerializer()) { ser.acceptJsonFormatVisitor(new JsonFormatVisitorWrapper.Base(provider) { // an unwrapping serializer will always expect ObjectFormat, // hence, the other cases do not have to be implemented @Override public JsonObjectFormatVisitor expectObjectFormat(JavaType type) throws JsonMappingException { return visitor; } }, this.getType()); } else { super.depositSchemaProperty(visitor, provider); } }
Example #2
Source File: RangeSerializer.java From jackson-datatypes-collections with Apache License 2.0 | 6 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonObjectFormatVisitor objectVisitor = visitor.expectObjectFormat(typeHint); if (objectVisitor != null) { if (_endpointSerializer != null) { JavaType endpointType = _rangeType.containedType(0); JavaType btType = visitor.getProvider().constructType(BoundType.class); // should probably keep track of `property`... JsonSerializer<?> btSer = visitor.getProvider() .findContentValueSerializer(btType, null); objectVisitor.property(_fieldNames.lowerEndpoint, _endpointSerializer, endpointType); objectVisitor.property(_fieldNames.lowerBoundType, btSer, btType); objectVisitor.property(_fieldNames.upperEndpoint, _endpointSerializer, endpointType); objectVisitor.property(_fieldNames.upperBoundType, btSer, btType); } } } }
Example #3
Source File: MultimapSerializer.java From jackson-datatypes-collections with Apache License 2.0 | 6 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonMapFormatVisitor v2 = (visitor == null) ? null : visitor.expectMapFormat(typeHint); if (v2 != null) { v2.keyFormat(_keySerializer, _type.getKeyType()); JsonSerializer<?> valueSer = _valueSerializer; final JavaType vt = _type.getContentType(); final SerializerProvider prov = visitor.getProvider(); if (valueSer == null) { valueSer = _findAndAddDynamic(prov, vt); } final JsonSerializer<?> valueSer2 = valueSer; v2.valueFormat(new JsonFormatVisitable() { final JavaType arrayType = prov.getTypeFactory().constructArrayType(vt); @Override public void acceptJsonFormatVisitor( JsonFormatVisitorWrapper v3, JavaType hint3) throws JsonMappingException { JsonArrayFormatVisitor v4 = v3.expectArrayFormat(arrayType); if (v4 != null) { v4.itemsFormat(valueSer2, vt); } } }, vt); } }
Example #4
Source File: MonetaryAmountSerializer.java From jackson-datatype-money with MIT License | 6 votes |
@Override public void acceptJsonFormatVisitor(final JsonFormatVisitorWrapper wrapper, final JavaType hint) throws JsonMappingException { @Nullable final JsonObjectFormatVisitor visitor = wrapper.expectObjectFormat(hint); if (visitor == null) { return; } final SerializerProvider provider = wrapper.getProvider(); visitor.property(names.getAmount(), provider.findValueSerializer(writer.getType()), provider.constructType(writer.getType())); visitor.property(names.getCurrency(), provider.findValueSerializer(CurrencyUnit.class), provider.constructType(CurrencyUnit.class)); visitor.optionalProperty(names.getFormatted(), provider.findValueSerializer(String.class), provider.constructType(String.class)); }
Example #5
Source File: ObjectArraySerializer.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonArrayFormatVisitor arrayVisitor = visitor.expectArrayFormat(typeHint); if (arrayVisitor != null) { JavaType contentType = _elementType; // [databind#1793]: Was getting `null` for `typeHint`. But why would we even use it... /* TypeFactory tf = visitor.getProvider().getTypeFactory(); contentType = tf.moreSpecificType(_elementType, typeHint.getContentType()); if (contentType == null) { visitor.getProvider().reportBadDefinition(_elementType, "Could not resolve type: "+_elementType); } */ JsonSerializer<?> valueSer = _elementSerializer; if (valueSer == null) { valueSer = visitor.getProvider().findValueSerializer(contentType, _property); } arrayVisitor.itemsFormat(valueSer, contentType); } }
Example #6
Source File: LocalDateSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { SerializerProvider provider = visitor.getProvider(); boolean useTimestamp = (provider != null) && useTimestamp(provider); if (useTimestamp) { _acceptTimestampVisitor(visitor, typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE); } } }
Example #7
Source File: StdScalarSerializer.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { // 13-Sep-2013, tatu: Let's assume it's usually a String, right? visitStringFormat(visitor, typeHint); }
Example #8
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.INTEGER); } } }
Example #9
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.INTEGER); } } }
Example #10
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.INTEGER); } } }
Example #11
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.INTEGER); } } }
Example #12
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.NUMBER); } } }
Example #13
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.NUMBER); } } }
Example #14
Source File: HppcContainerSerializers.java From jackson-datatypes-collections with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.BOOLEAN); } } }
Example #15
Source File: YearMonthSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@Override protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { SerializerProvider provider = visitor.getProvider(); boolean useTimestamp = (provider != null) && useTimestamp(provider); if (useTimestamp) { super._acceptTimestampVisitor(visitor, typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } }
Example #16
Source File: DurationSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@Override protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); SerializerProvider provider = visitor.getProvider(); if ((provider != null) && useNanoseconds(provider)) { // big number, no more specific qualifier to use... } else { // otherwise good old Unix timestamp, in milliseconds v2.format(JsonValueFormat.UTC_MILLISEC); } } }
Example #17
Source File: LocalTimeSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (useTimestamp(visitor.getProvider())) { _acceptTimestampVisitor(visitor, typeHint); } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.TIME); } } }
Example #18
Source File: DefaultSerializerProvider.java From lams with GNU General Public License v2.0 | 5 votes |
/** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * to to expose the format of the given to to the given visitor * * @param javaType The type for which to generate format * @param visitor the visitor to accept the format */ public void acceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (javaType == null) { throw new IllegalArgumentException("A class must be provided"); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ visitor.setProvider(this); findValueSerializer(javaType, null).acceptJsonFormatVisitor(visitor, javaType); }
Example #19
Source File: YearSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@Override protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); } }
Example #20
Source File: DataHandlerJsonSerializer.java From jackson-modules-base with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.STRING); } } }
Example #21
Source File: MonetaryAmountSerializerTest.java From jackson-datatype-money with MIT License | 5 votes |
@Test void shouldHandleNullValueFromExpectObjectFormatInSchemaVisitor() throws Exception { final MonetaryAmountSerializer unit = new MonetaryAmountSerializer(FieldNames.defaults(), new DecimalAmountWriter(), MonetaryAmountFormatFactory.NONE); final JsonFormatVisitorWrapper wrapper = mock(JsonFormatVisitorWrapper.class); unit.acceptJsonFormatVisitor(wrapper, SimpleType.constructUnsafe(MonetaryAmount.class)); }
Example #22
Source File: FieldDocumentationObjectVisitor.java From spring-auto-restdocs with Apache License 2.0 | 5 votes |
private void visitType(BeanProperty prop, String jsonName, String fieldName, JavaType fieldType, JsonSerializer<?> ser, boolean required) throws JsonMappingException { String fieldPath = path + (path.isEmpty() ? "" : ".") + jsonName; log.debug("({}) {}", fieldPath, fieldType.getRawClass().getSimpleName()); Class<?> javaBaseClass = prop.getMember().getDeclaringClass(); boolean shouldExpand = shouldExpand(prop); InternalFieldInfo fieldInfo = new InternalFieldInfo(javaBaseClass, fieldName, fieldType, fieldPath, shouldExpand, required); JsonFormatVisitorWrapper visitor = new FieldDocumentationVisitorWrapper(getProvider(), context, fieldPath, fieldInfo, typeRegistry, typeFactory, skipAccessor); ser.acceptJsonFormatVisitor(visitor, fieldType); }
Example #23
Source File: FieldDocumentationArrayVisitor.java From spring-auto-restdocs with Apache License 2.0 | 5 votes |
@Override public void itemsFormat(JsonFormatVisitable handler, JavaType elementType) throws JsonMappingException { String elementPath = path + "[]"; JsonFormatVisitorWrapper visitor = new FieldDocumentationVisitorWrapper(getProvider(), context, elementPath, null, typeRegistry, typeFactory, skipAccessor); handler.acceptJsonFormatVisitor(visitor, elementType); }
Example #24
Source File: BigDecimalSerializer.java From spring-auto-restdocs with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { visitor.expectNumberFormat(typeHint); } }
Example #25
Source File: MoneySerializer.java From spring-auto-restdocs with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { visitor.expectStringFormat(typeHint); } }
Example #26
Source File: ObjectMappers.java From glowroot with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { visitor.expectBooleanFormat(typeHint); } }
Example #27
Source File: StoredAsJsonSerializer.java From Rosetta with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // try/catch is for 2.1.x compatibility try { DELEGATE.acceptJsonFormatVisitor(visitor, typeHint); } catch (Exception e) { throw new RuntimeException(e); } }
Example #28
Source File: ConstantBinarySerializer.java From Rosetta with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // try/catch is for 2.1.x compatibility try { DELEGATE.acceptJsonFormatVisitor(visitor, typeHint); } catch (Exception e) { throw new RuntimeException(e); } }
Example #29
Source File: StoredAsJsonBinarySerializer.java From Rosetta with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // try/catch is for 2.1.x compatibility try { DELEGATE.acceptJsonFormatVisitor(visitor, typeHint); } catch (Exception e) { throw new RuntimeException(e); } }
Example #30
Source File: ConstantSerializer.java From Rosetta with Apache License 2.0 | 5 votes |
@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // try/catch is for 2.1.x compatibility try { DELEGATE.acceptJsonFormatVisitor(visitor, typeHint); } catch (Exception e) { throw new RuntimeException(e); } }