Java Code Examples for com.fasterxml.jackson.databind.BeanProperty#getAnnotation()
The following examples show how to use
com.fasterxml.jackson.databind.BeanProperty#getAnnotation() .
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 |
@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 |
@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 |
@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: TextFieldSchemaDecorator.java From sf-java-ui with MIT License | 6 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { TextField annotation = property.getAnnotation(TextField.class); if (annotation != null) { if (annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } if (annotation.pattern() != null) { ((StringSchema) jsonschema).setPattern(annotation.pattern()); } if (annotation.minLenght() != 0) { ((StringSchema) jsonschema).setMinLength(annotation.minLenght()); } if (annotation.maxLenght() != Integer.MAX_VALUE) { ((StringSchema) jsonschema).setMaxLength(annotation.maxLenght()); } } }
Example 5
Source File: SensitiveSerialize.java From Resource with GNU General Public License v3.0 | 6 votes |
@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); }
Example 6
Source File: JacksonXSSDeserializer.java From youran with Apache License 2.0 | 5 votes |
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { if (property != null) { IgnoreXSS annotation = property.getAnnotation(IgnoreXSS.class); if (annotation != null) { return StringDeserializer.instance; } } return this; }
Example 7
Source File: CheckBoxSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { CheckBox annotation = property.getAnnotation(CheckBox.class); if (annotation != null && annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } }
Example 8
Source File: NumberSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { Number annotation = property.getAnnotation(Number.class); if (annotation != null && annotation.title() != null) { ((SimpleTypeSchema) jsonschema).setTitle(annotation.title()); } }
Example 9
Source File: RadioBoxSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { RadioBox annotation = property.getAnnotation(RadioBox.class); if (annotation != null && annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } }
Example 10
Source File: ComboBoxSchemaDecorator.java From sf-java-ui with MIT License | 5 votes |
@Override public void customizeSchema(BeanProperty property, JsonSchema jsonschema) { ComboBox annotation = property.getAnnotation(ComboBox.class); if (annotation != null && annotation.title() != null) { ((StringSchema) jsonschema).setTitle(annotation.title()); } }