org.springframework.boot.configurationmetadata.ValueProvider Java Examples
The following examples show how to use
org.springframework.boot.configurationmetadata.ValueProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultValueHintProvider.java From spring-cloud-dashboard with Apache License 2.0 | 5 votes |
@Override public boolean isExclusive(ConfigurationMetadataProperty property) { for (ValueProvider valueProvider : property.getValueProviders()) { if ("any".equals(valueProvider.getName())) { return false; } } return true; }
Example #2
Source File: DefaultValueHintProvider.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Override public boolean isExclusive(ConfigurationMetadataProperty property) { for (ValueProvider valueProvider : property.getHints().getValueProviders()) { if ("any".equals(valueProvider.getName())) { return false; } } return true; }
Example #3
Source File: CfgPropsCompletionQuery.java From nb-springboot with Apache License 2.0 | 4 votes |
private void completePropName(CompletionResultSet completionResultSet, String filter, int startOffset, int caretOffset) { final Preferences prefs = NbPreferences.forModule(PrefConstants.class); final boolean bDeprLast = prefs.getBoolean(PREF_DEPR_SORT_LAST, true); final boolean bErrorShow = prefs.getBoolean(PREF_DEPR_ERROR_SHOW, true); long mark = System.currentTimeMillis(); // check if completing a property map key if (filter != null) { ClassPath cpExec = Utils.execClasspathForProj(proj); for (String mapProp : sbs.getMapPropertyNames()) { if (filter.length() > mapProp.length() && filter.contains(mapProp)) { String key = filter.substring(mapProp.length() + 1); logger.log(FINER, "Completing key for map property {0} from: ''{1}''", new Object[]{mapProp, key}); final ConfigurationMetadataProperty propMetadata = sbs.getPropertyMetadata(mapProp); // if key data type is an enum complete with enum values final String keyDataType = extractMapKeyType(propMetadata); if (!keyDataType.contains("<")) { Utils.completeEnum(cpExec, keyDataType, key, hint -> { completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1, caretOffset)); }); } // check if key data type is boolean if (keyDataType.equals("java.lang.Boolean")) { Utils.completeBoolean(key, hint -> { completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1, caretOffset)); }); } // check if key data type is Charset if (keyDataType.equals("java.nio.charset.Charset")) { Utils.completeCharset(key, hint -> { completionResultSet.addItem(new KeyCompletionItem(hint, startOffset + mapProp.length() + 1, caretOffset)); }); } // add metadata defined key hints to completion list final Hints hints = propMetadata.getHints(); if (!hints.getKeyHints().isEmpty()) { String keyLowcase = key.toLowerCase(); for (ValueHint keyHint : hints.getKeyHints()) { if (keyHint.getValue().toString().toLowerCase().contains(keyLowcase)) { completionResultSet.addItem(new KeyCompletionItem(keyHint, startOffset + mapProp.length() + 1, caretOffset)); } } } // invoke key providers if (!hints.getKeyProviders().isEmpty()) { logger.log(FINER, "Key providers for {0}:", mapProp); for (ValueProvider vp : hints.getKeyProviders()) { logger.log(FINER, " {0} - params: {1}", new Object[]{vp.getName(), vp.getParameters()}); sbs.getHintProvider(vp.getName()).provide(vp.getParameters(), propMetadata, key, true, completionResultSet, startOffset + mapProp.length() + 1, caretOffset); } } } } } for (ConfigurationMetadataProperty propMeta : sbs.queryPropertyMetadata(filter)) { if (Utils.isErrorDeprecated(propMeta)) { // show error level deprecated props based on pref if (bErrorShow) { completionResultSet.addItem(new CfgPropCompletionItem(propMeta, startOffset, caretOffset, bDeprLast)); } } else { completionResultSet.addItem(new CfgPropCompletionItem(propMeta, startOffset, caretOffset, bDeprLast)); } } final long elapsed = System.currentTimeMillis() - mark; logger.log(FINE, "Name completion of ''{0}'' took: {1} msecs", new Object[]{filter, elapsed}); }
Example #4
Source File: DumpBootCfgPropsMetadataAction.java From nb-springboot with Apache License 2.0 | 4 votes |
private void dumpToCsv(SpringBootService sbs, Path path) { try (BufferedWriter bw = Files.newBufferedWriter(path); PrintWriter pw = new PrintWriter(bw)) { pw.println("Name,DataType," + "HasKeyHints,KeyProvider,KeyProviderParams," + "HasValueHints,ValueProvider,ValueProviderParams," + "Default"); for (String name : new TreeSet<>(sbs.getPropertyNames())) { ConfigurationMetadataProperty cfg = sbs.getPropertyMetadata(name); // skip deprecated properties if (cfg.isDeprecated()) { continue; } String dataType = cfg.getType(); String hasKeyHints = ""; String hasValueHints = ""; String keyProvider = ""; String keyProviderParams = ""; String valueProvider = ""; String valueProviderParams = ""; Hints hints = cfg.getHints(); if (hints != null) { hasKeyHints = !hints.getKeyHints().isEmpty() ? "T" : "F"; if (!hints.getKeyProviders().isEmpty()) { ValueProvider kp = hints.getKeyProviders().get(0); keyProvider = kp.getName(); keyProviderParams = kp.getParameters().toString(); } hasValueHints = !hints.getValueHints().isEmpty() ? "T" : "F"; if (!hints.getValueProviders().isEmpty()) { ValueProvider vp = hints.getValueProviders().get(0); valueProvider = vp.getName(); valueProviderParams = vp.getParameters().toString(); } } else { System.out.format("%s has null hints object%n", name); } String defaultValue = ""; final Object def = cfg.getDefaultValue(); if (def != null) { if (def.getClass().isArray()) { defaultValue = Arrays.toString((Object[]) def); } else { defaultValue = String.valueOf(def); } } String row = String.format("%s,\"%s\",%s,%s,%s,%s,%s,%s,\"%s\"", name, dataType, hasKeyHints, keyProvider, keyProviderParams, hasValueHints, valueProvider, valueProviderParams, defaultValue); pw.println(row); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } }