Java Code Examples for com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor#property()

The following examples show how to use com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor#property() . 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: RangeSerializer.java    From jackson-datatypes-collections with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: MonetaryAmountSerializer.java    From jackson-datatype-money with MIT License 6 votes vote down vote up
@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 3
Source File: BeanPropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void depositSchemaProperty(JsonObjectFormatVisitor v,
        SerializerProvider provider) throws JsonMappingException {
    if (v != null) {
        if (isRequired()) {
            v.property(this);
        } else {
            v.optionalProperty(this);
        }
    }
}
 
Example 4
Source File: SettableBeanProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor,
        SerializerProvider provider)
    throws JsonMappingException
{
    if (isRequired()) {
        objectVisitor.property(this); 
    } else {
        objectVisitor.optionalProperty(this);
    }
}