Example usage for org.springframework.boot.configurationmetadata ConfigurationMetadataProperty getId

List of usage examples for org.springframework.boot.configurationmetadata ConfigurationMetadataProperty getId

Introduction

In this page you can find the example usage for org.springframework.boot.configurationmetadata ConfigurationMetadataProperty getId.

Prototype

public String getId() 

Source Link

Document

The full identifier of the property, in lowercase dashed form (e.g.

Usage

From source file:demo.config.diff.ConfigDiffSample.java

private static StringBuilder appendProperty(StringBuilder sb, ConfigurationMetadataProperty property,
        boolean add) {
    String symbol = add ? "[+]" : "[-]";
    sb.append(symbol).append(" ").append(property.getId());
    String shortDescription = property.getShortDescription();
    if (StringUtils.hasText(shortDescription)) {
        sb.append(" - ").append(shortDescription);
    }//from  w w  w  . j ava 2s  .  com
    return sb;
}

From source file:demo.config.diff.ConfigDiffGenerator.java

protected ConfigGroupDiff generateGroupDiff(ConfigurationMetadataGroup left, ConfigurationMetadataGroup right) {
    ConfigGroupDiff group = new ConfigGroupDiff(left.getId(), left, right);
    List<String> matches = new ArrayList<>();
    Map<String, ConfigurationMetadataProperty> leftProperties = left.getProperties();
    Map<String, ConfigurationMetadataProperty> rightProperties = right.getProperties();
    for (ConfigurationMetadataProperty leftProperty : leftProperties.values()) {
        String id = leftProperty.getId();
        ConfigurationMetadataProperty rightProperty = rightProperties.get(id);
        if (rightProperty == null) {
            group.register(ConfigDiffType.DELETE,
                    new ConfigPropertyDiff(leftProperty.getId(), leftProperty, null));
        } else {/*ww  w. ja  v a2  s .c o  m*/
            matches.add(id);
            group.register(ConfigDiffType.EQUALS, // NICE: handle diff in property def
                    new ConfigPropertyDiff(leftProperty.getId(), leftProperty, rightProperty));
        }
    }
    for (ConfigurationMetadataProperty rightProperty : rightProperties.values()) {
        if (!matches.contains(rightProperty.getId())) {
            group.register(ConfigDiffType.ADD,
                    new ConfigPropertyDiff(rightProperty.getId(), null, rightProperty));
        }
    }
    return group;
}

From source file:demo.config.diff.ConfigDiffGenerator.java

private boolean equals(ConfigurationMetadataGroup left, ConfigurationMetadataGroup right) {
    if (left.getProperties().size() != right.getProperties().size()) {
        return false;
    }/*from  w  ww.j  a v a2  s. c om*/
    for (ConfigurationMetadataProperty property : left.getProperties().values()) {
        if (!right.getProperties().containsKey(property.getId())) {
            return false;
        }
    }
    return true;
}

From source file:demo.config.diff.ConfigDiffGenerator.java

protected ConfigDiffGenerator diffGroup(ConfigDiffResult result, ConfigurationMetadataRepository left,
        ConfigurationMetadataRepository right) {
    List<String> matches = new ArrayList<>();
    Map<String, ConfigurationMetadataGroup> leftGroups = left.getAllGroups();
    Map<String, ConfigurationMetadataGroup> rightGroups = right.getAllGroups();
    for (ConfigurationMetadataGroup leftGroup : leftGroups.values()) {
        String id = leftGroup.getId();
        ConfigurationMetadataGroup rightGroup = rightGroups.get(id);
        if (rightGroup == null) {
            ConfigGroupDiff groupDiff = new ConfigGroupDiff(id, leftGroup, null);
            for (ConfigurationMetadataProperty property : leftGroup.getProperties().values()) {
                groupDiff.register(ConfigDiffType.DELETE,
                        new ConfigPropertyDiff(property.getId(), property, null));
            }/*from  w w  w .j  av a2 s  . co  m*/
            result.register(ConfigDiffType.DELETE, groupDiff);
        } else {
            matches.add(id);
            ConfigDiffType diffType = (equals(leftGroup, rightGroup) ? ConfigDiffType.EQUALS
                    : ConfigDiffType.MODIFY);
            result.register(diffType, generateGroupDiff(leftGroup, rightGroup));
        }
    }
    for (ConfigurationMetadataGroup rightGroup : rightGroups.values()) {
        if (!matches.contains(rightGroup.getId())) {
            ConfigGroupDiff groupDiff = new ConfigGroupDiff(rightGroup.getId(), null, rightGroup);
            for (ConfigurationMetadataProperty property : rightGroup.getProperties().values()) {
                groupDiff.register(ConfigDiffType.ADD,
                        new ConfigPropertyDiff(property.getId(), null, property));
            }
            result.register(ConfigDiffType.ADD, groupDiff);
        }
    }
    return this;
}

From source file:com.github.alexfalappa.nbspringboot.cfgprops.completion.CfgPropCompletionDocumentation.java

@Override
public String getText() {
    ConfigurationMetadataProperty configurationMeta = item.getConfigurationMetadata();
    StringBuilder sb = new StringBuilder();
    // name and type
    sb.append("<b>").append(configurationMeta.getId()).append("</b>");
    sb.append("<br/>").append(simpleHtmlEscape(configurationMeta.getType()));
    // deprecation (optional)
    Deprecation deprecation = configurationMeta.getDeprecation();
    if (deprecation != null) {
        sb.append("<br/><br/><b><i>");
        if (Utils.isErrorDeprecated(configurationMeta)) {
            sb.append("REMOVED");
        } else {/*from   ww  w .j  a  v  a  2 s. c  o m*/
            sb.append("Deprecated");
        }
        // deprecation reason if present
        String reason = deprecation.getReason();
        if (reason != null) {
            sb.append(":</i></b> ").append(simpleHtmlEscape(reason));
        } else {
            sb.append("</i></b>");
        }
        String replacement = deprecation.getReplacement();
        if (replacement != null) {
            sb.append("<br/><i>Replaced by:</i> <code>").append(replacement).append("</code>");
        }
    }
    // default value (optional)
    final Object defaultValue = configurationMeta.getDefaultValue();
    if (null != defaultValue) {
        sb.append("<br/><br/><i>Default:</i> ");
        if (defaultValue instanceof Object[]) {
            sb.append(Arrays.toString((Object[]) defaultValue));
        } else {
            sb.append(String.valueOf(defaultValue));
        }
    }
    // description (optional)
    final String description = configurationMeta.getDescription();
    if (description != null) {
        sb.append("<br/><br/>").append(description);
    }
    // list of values (optional)
    Hints hints = configurationMeta.getHints();
    List<ValueHint> valueHints = hints.getValueHints();
    if (valueHints != null && !valueHints.isEmpty()) {
        sb.append("<br/><br/><table><tr><td><i>Value</i></td><td><i>Description</i></td></tr>");
        for (ValueHint vHint : valueHints) {
            sb.append("<tr><td>").append(vHint.getValue()).append("</td><td>");
            final String vDesc = vHint.getDescription();
            if (vDesc != null) {
                sb.append(simpleHtmlEscape(vDesc)).append("</th></tr>");
            }
        }
        sb.append("</table>");
    }
    return sb.toString();
}

From source file:com.github.alexfalappa.nbspringboot.projects.customizer.CfgPropsDialog.java

private void filterProps(String filter) {
    DefaultListModel<ConfigurationMetadataProperty> dlmCfgProps = new DefaultListModel<>();
    for (ConfigurationMetadataProperty item : sortedProps) {
        if (filter == null || item.getId().contains(filter)) {
            if (Utils.isErrorDeprecated(item)) {
                if (bDeprErrorShow) {
                    dlmCfgProps.addElement(item);
                }//from ww  w  . j a v  a2  s.c o  m
            } else {
                dlmCfgProps.addElement(item);
            }
        }
    }
    lCfgProps.setModel(dlmCfgProps);
    if (!dlmCfgProps.isEmpty()) {
        lCfgProps.setSelectedIndex(0);
    }
}