Search in sources :

Example 1 with Description

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()));
    }
}
Also used : Description(com.torodb.packaging.config.annotation.Description)

Example 2 with Description

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("");
        }
    }
}
Also used : Field(java.lang.reflect.Field) JavaType(com.fasterxml.jackson.databind.JavaType) Description(com.torodb.packaging.config.annotation.Description)

Aggregations

Description (com.torodb.packaging.config.annotation.Description)2 JavaType (com.fasterxml.jackson.databind.JavaType)1 Field (java.lang.reflect.Field)1