com.fasterxml.jackson.databind.annotation.JsonNaming Java Examples

The following examples show how to use com.fasterxml.jackson.databind.annotation.JsonNaming. 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: JacksonModule.java    From jsonschema-generator with Apache License 2.0 5 votes vote down vote up
/**
 * Look-up the given type's {@link JsonNaming} annotation and instantiate the declared {@link PropertyNamingStrategy}.
 *
 * @param declaringType type declaring fields for which the applicable naming strategy should be looked-up
 * @return annotated naming strategy instance (or {@code null})
 */
private PropertyNamingStrategy getAnnotatedNamingStrategy(Class<?> declaringType) {
    return Optional.ofNullable(declaringType.getAnnotation(JsonNaming.class))
            .map(JsonNaming::value)
            .map(strategyType -> {
                try {
                    return strategyType.newInstance();
                } catch (InstantiationException | IllegalAccessException ex) {
                    return null;
                }
            })
            .orElse(null);
}