Java Code Examples for com.fasterxml.jackson.databind.SerializerProvider#findNullValueSerializer()

The following examples show how to use com.fasterxml.jackson.databind.SerializerProvider#findNullValueSerializer() . 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: DoubleSpecifySerialize.java    From jframework with Apache License 2.0 6 votes vote down vote up
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
    // 为空直接跳过
    if (property == null) {
        return prov.findNullValueSerializer(property);
    }
    // 非 Double 类直接跳过
    if (Objects.equals(property.getType().getRawClass(), Double.class)) {
        DoubleSpecify doubleSpecify = property.getAnnotation(DoubleSpecify.class);
        if (doubleSpecify == null) {
            doubleSpecify = property.getContextAnnotation(DoubleSpecify.class);
        }
        // 如果能得到注解,就将注解的 value 传入 DoubleSpecifySerialize
        if (doubleSpecify != null) {
            return new DoubleSpecifySerialize(doubleSpecify.value());
        }
    }
    return prov.findValueSerializer(property.getType(), property);
}
 
Example 2
Source File: BigDecimalSpecifySerialize.java    From jframework with Apache License 2.0 6 votes vote down vote up
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
    // 为空直接跳过
    if (property == null) {
        return prov.findNullValueSerializer(property);
    }
    // 非 BigDecimal 类直接跳过
    if (Objects.equals(property.getType().getRawClass(), BigDecimal.class)) {
        BigDecimalSpecify doubleSpecify = property.getAnnotation(BigDecimalSpecify.class);
        if (doubleSpecify == null) {
            doubleSpecify = property.getContextAnnotation(BigDecimalSpecify.class);
        }
        // 如果能得到注解,就将注解的 value 传入 BigDecimalSpecifySerialize
        if (doubleSpecify != null) {
            return new BigDecimalSpecifySerialize(doubleSpecify.value());
        }
    }
    return prov.findValueSerializer(property.getType(), property);
}
 
Example 3
Source File: SensitiveInfoSerialize.java    From pre with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JsonSerializer<?> createContextual(final SerializerProvider serializerProvider, final BeanProperty beanProperty) throws JsonMappingException {
    // 为空直接跳过
    if (beanProperty != null) {
        // 非 String 类直接跳过
        if (Objects.equals(beanProperty.getType().getRawClass(), String.class)) {
            SensitiveInfo sensitiveInfo = beanProperty.getAnnotation(SensitiveInfo.class);
            if (sensitiveInfo == null) {
                sensitiveInfo = beanProperty.getContextAnnotation(SensitiveInfo.class);
            }
            // 如果能得到注解,就将注解的 value 传入 SensitiveInfoSerialize
            if (sensitiveInfo != null) {
                return new SensitiveInfoSerialize(sensitiveInfo.value());
            }
        }
        return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
    }
    return serializerProvider.findNullValueSerializer(beanProperty);
}
 
Example 4
Source File: SensitiveSerialize.java    From Resource with GNU General Public License v3.0 6 votes vote down vote up
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
    throws JsonMappingException
{
    if (property != null)
    {   // 为空直接跳过
        if (Objects.equals(property.getType().getRawClass(), String.class))
        { // 非 String 类直接跳过
            SensitiveInfo sensitiveInfo = property.getAnnotation(SensitiveInfo.class);
            if (sensitiveInfo == null)
            {
                sensitiveInfo = property.getContextAnnotation(SensitiveInfo.class);
            }
            if (sensitiveInfo != null)
            {   // 如果能得到注解,就将注解的 value 传入 SensitiveInfoSerialize
                SensitiveSerialize serialize = new SensitiveSerialize();
                serialize.type = sensitiveInfo.value();
                return serialize;
            }
        }
        return prov.findValueSerializer(property.getType(), property);
    }
    return prov.findNullValueSerializer(property);
}