use of org.walkmod.conf.entities.BeanDefinition in project walkmod-core by walkmod.
the class InspectCommand method execute.
@Override
public void execute() throws Exception {
if (help) {
command.usage("inspect");
} else {
WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().offline(offline));
List<BeanDefinition> beans = facade.inspectPlugin(new PluginConfigImpl(pluginId.get(0)));
List<String> validTypesList = Arrays.asList("String", "JSONObject", "JSONArray");
if (beans != null) {
at = new V2_AsciiTable();
at.addRule();
at.addRow("TYPE NAME (ID)", "CATEGORY", "PROPERTIES", "DESCRIPTION");
at.addStrongRule();
for (BeanDefinition bean : beans) {
List<PropertyDefinition> properties = bean.getProperties();
if (properties == null || properties.isEmpty()) {
at.addRow(bean.getType(), bean.getCategory(), "", bean.getDescription());
} else {
int i = 0;
for (PropertyDefinition pd : properties) {
if (validTypesList.contains(pd.getType())) {
String label = pd.getName() + ":" + pd.getType();
if (pd.getDefaultValue() != null && pd.getDefaultValue().length() != 0) {
label = label + " (" + pd.getDefaultValue() + ")";
}
if (i == 0) {
at.addRow(bean.getType(), bean.getCategory(), label, bean.getDescription());
} else {
at.addRow("", "", label, "");
}
i++;
}
}
}
at.addRule();
}
}
}
}
Aggregations