下面列出了怎么用com.fasterxml.jackson.databind.annotation.JsonNaming的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* 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);
}