use of com.torodb.packaging.config.annotation.Description in project torodb by torodb.
the class DescriptionFactoryWrapper method printDescription.
private void printDescription(BeanProperty prop) {
Description description = getDescription(prop);
if (description != null) {
console.print(" # ");
console.print(resourceBundle.getString(description.value()));
}
}
use of com.torodb.packaging.config.annotation.Description in project torodb by torodb.
the class DescriptionFactoryWrapper method document.
private void document(JsonPointer propPointer, BeanProperty prop) {
JavaType type = prop.getType();
if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType() && !type.isMapLikeType()) {
console.println("");
} else if (isPrimitive(type) || type.isEnumType()) {
printTabs();
console.print(propPointer.toString());
console.print("=");
} else if (type.isMapLikeType()) {
printTabs();
console.print(propPointer.append(JsonPointer.compile("/<string>")).toString());
console.print("=");
type = type.getContentType();
}
if (isPrimitive(type)) {
console.print("<");
console.print(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, type.getRawClass().getSimpleName()));
console.print(">");
} else if (type.isEnumType()) {
console.print("<enum:string>");
}
if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
printTabs();
}
printDescription(prop);
if (hasDescription(prop) || isPrimitive(type) || type.isEnumType()) {
console.println("");
}
if (hasDescription(prop) && !isPrimitive(type) && !type.isEnumType()) {
console.println("");
}
if (type.isEnumType()) {
for (Field enumField : type.getRawClass().getDeclaredFields()) {
if (!enumField.isEnumConstant()) {
continue;
}
printTabs();
console.print(" - ");
console.print(enumField.getName());
Description enumConstantConfigProperty = enumField.getAnnotation(Description.class);
if (enumConstantConfigProperty != null && enumConstantConfigProperty.value() != null) {
console.print(" # ");
console.print(resourceBundle.getString(enumConstantConfigProperty.value()));
}
console.println("");
}
}
}
Aggregations