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();
}
}
Aggregations