Search in sources :

Example 1 with BeanDefinition

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();
            }
        }
    }
}
Also used : V2_AsciiTable(de.vandermeer.asciitable.v2.V2_AsciiTable) WalkModFacade(org.walkmod.WalkModFacade) BeanDefinition(org.walkmod.conf.entities.BeanDefinition) PluginConfigImpl(org.walkmod.conf.entities.impl.PluginConfigImpl) PropertyDefinition(org.walkmod.conf.entities.PropertyDefinition)

Aggregations

V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)1 WalkModFacade (org.walkmod.WalkModFacade)1 BeanDefinition (org.walkmod.conf.entities.BeanDefinition)1 PropertyDefinition (org.walkmod.conf.entities.PropertyDefinition)1 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)1