下面列出了怎么用com.fasterxml.jackson.annotation.JsonClassDescription的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected DeclarationModel parseClass(SourceType<Class<?>> sourceClass) {
final List<String> classComments = getComments(sourceClass.type.getAnnotation(JsonClassDescription.class));
if (sourceClass.type.isEnum()) {
return parseEnumOrObjectEnum(sourceClass, classComments);
} else {
return parseBean(sourceClass, classComments);
}
}
private static List<String> getComments(JsonClassDescription classDescriptionAnnotation) {
final String propertyDescriptionValue = classDescriptionAnnotation != null ? classDescriptionAnnotation.value() : null;
final List<String> classComments = Utils.splitMultiline(propertyDescriptionValue, false);
return classComments;
}
/**
* Determine the given type's associated "description" via the following annotation.
* <ul>
* <li>{@link JsonClassDescription} annotation on the targeted type's class</li>
* </ul>
*
* @param scope scope for which to collect an available description
* @return successfully looked-up description (or {@code null})
*/
protected String resolveDescriptionForType(TypeScope scope) {
Class<?> rawType = scope.getType().getErasedType();
JsonClassDescription classAnnotation = rawType.getAnnotation(JsonClassDescription.class);
if (classAnnotation != null) {
return classAnnotation.value();
}
return null;
}