Search in sources :

Example 6 with Documentation

use of oms3.annotations.Documentation in project hortonmachine by TheHortonMachine.

the class JGrassGears method main.

public static void main(String[] args) throws IOException {
    JGrassGears jgr = getInstance();
    Set<Entry<String, Class<?>>> cls = jgr.moduleName2Class.entrySet();
    for (Entry<String, Class<?>> cl : cls) {
        System.out.println(cl.getValue().getCanonicalName());
    }
    Map<String, List<ClassField>> moduleName2Fields = jgr.moduleName2Fields;
    Map<String, Class<?>> moduleName2Class = jgr.moduleName2Class;
    Set<Entry<String, List<ClassField>>> entrySet = moduleName2Fields.entrySet();
    for (Entry<String, List<ClassField>> entry : entrySet) {
        String moduleName = entry.getKey();
        StringBuilder sb = new StringBuilder();
        Class<?> moduleClass = moduleName2Class.get(moduleName);
        Description description = moduleClass.getAnnotation(Description.class);
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_DESCRIPTION = \"" + description.value() + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Documentation documentation = moduleClass.getAnnotation(Documentation.class);
        String doc;
        if (documentation == null) {
            doc = "";
        } else {
            doc = documentation.value();
        }
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_DOCUMENTATION = \"" + doc + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Keywords keywords = moduleClass.getAnnotation(Keywords.class);
        String k;
        if (keywords == null) {
            k = "";
        } else {
            k = keywords.value();
        }
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_KEYWORDS = \"" + k + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Label label = moduleClass.getAnnotation(Label.class);
        String lab;
        if (label == null) {
            lab = "";
        } else {
            lab = label.value();
        }
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_LABEL = \"" + lab + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Name name = moduleClass.getAnnotation(Name.class);
        String n;
        if (name == null) {
            n = "";
        } else {
            n = name.value();
        }
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_NAME = \"" + n + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Status status = moduleClass.getAnnotation(Status.class);
        sb.append("public static final int " + moduleName.toUpperCase() + "_STATUS = " + status.value() + ";\n");
        License license = moduleClass.getAnnotation(License.class);
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_LICENSE = \"" + license.value() + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        Author author = moduleClass.getAnnotation(Author.class);
        String authorName = author.name();
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_AUTHORNAMES = \"" + authorName + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        String authorContact = author.contact();
        sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_AUTHORCONTACTS = \"" + authorContact + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        UI ui = moduleClass.getAnnotation(UI.class);
        if (ui != null) {
            sb.append(PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_UI = \"" + ui.value() + QUOTATION_MARK_SEMICOLON_NEW_LINE);
        }
        List<ClassField> value = entry.getValue();
        for (ClassField classField : value) {
            String fieldName = classField.fieldName;
            if (fieldName.equals("pm")) {
                continue;
            }
            String fieldDescription = classField.fieldDescription;
            String str = PUBLIC_STATIC_FINAL_STRING + moduleName.toUpperCase() + "_" + fieldName + "_DESCRIPTION = \"" + fieldDescription + QUOTATION_MARK_SEMICOLON_NEW_LINE;
            sb.append(str);
        }
        System.out.println(sb.toString());
        System.out.println();
    }
}
Also used : Status(oms3.annotations.Status) Description(oms3.annotations.Description) Keywords(oms3.annotations.Keywords) Documentation(oms3.annotations.Documentation) Label(oms3.annotations.Label) License(oms3.annotations.License) Name(oms3.annotations.Name) Entry(java.util.Map.Entry) UI(oms3.annotations.UI) Author(oms3.annotations.Author) ArrayList(java.util.ArrayList) List(java.util.List) ClassField(org.hortonmachine.gears.libs.modules.ClassField)

Aggregations

Description (oms3.annotations.Description)6 Author (oms3.annotations.Author)5 Documentation (oms3.annotations.Documentation)5 Keywords (oms3.annotations.Keywords)5 License (oms3.annotations.License)5 Name (oms3.annotations.Name)5 ClassField (org.hortonmachine.gears.libs.modules.ClassField)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Entry (java.util.Map.Entry)4 Label (oms3.annotations.Label)4 Status (oms3.annotations.Status)4 UI (oms3.annotations.UI)4 Unit (oms3.annotations.Unit)2 File (java.io.File)1 Field (java.lang.reflect.Field)1 URL (java.net.URL)1 Access (oms3.Access)1