Example usage for org.springframework.boot.configurationmetadata ValueHint getValue

List of usage examples for org.springframework.boot.configurationmetadata ValueHint getValue

Introduction

In this page you can find the example usage for org.springframework.boot.configurationmetadata ValueHint getValue.

Prototype

public Object getValue() 

Source Link

Document

Return the hint value.

Usage

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

@Override
public String getText() {
    ValueHint valueHint = item.getHint();
    StringBuilder sb = new StringBuilder();
    // name and type
    sb.append("<b>").append(valueHint.getValue()).append("</b>");
    final String description = valueHint.getDescription();
    if (description != null) {
        sb.append("<br/>").append(simpleHtmlEscape(description));
    }//from  www .ja  va  2  s  . com
    return sb.toString();
}

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  . com*/
            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.service.spi.SpringBootServiceImpl.java

@Override
public List<ValueHint> queryHintMetadata(String propertyName, String filter) {
    if (cpExec == null) {
        init();//from ww w. j  a va 2 s.c  om
    }
    List<ValueHint> ret = new LinkedList<>();
    if (getPropertyNames().contains(propertyName)) {
        Hints hints = cachedProperties.get(propertyName).getHints();
        for (ValueHint valueHint : hints.getValueHints()) {
            if (filter == null || valueHint.getValue().toString().contains(filter)) {
                ret.add(valueHint);
            }
        }
    }
    return ret;
}