本文整理汇总了Java中org.springframework.boot.configurationmetadata.ValueHint类的典型用法代码示例。如果您正苦于以下问题:Java ValueHint类的具体用法?Java ValueHint怎么用?Java ValueHint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueHint类属于org.springframework.boot.configurationmetadata包,在下文中一共展示了ValueHint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryHintMetadata
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> queryHintMetadata(String propertyName, String filter) {
if (cpExec == null) {
init();
}
List<ValueHint> ret = new LinkedList<>();
ConfigurationMetadataProperty cfgMeta = getPropertyMetadata(propertyName);
if (cfgMeta != null) {
for (ValueHint valueHint : cfgMeta.getHints().getValueHints()) {
if (filter == null || valueHint.getValue().toString().contains(filter)) {
ret.add(valueHint);
}
}
}
return ret;
}
示例2: addValueHintsProposals
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
void addValueHintsProposals(final String dsl, AppRegistration appRegistration, final List<CompletionProposal> collector, final String propertyName, final ValueHintProvider[] valueHintProviders){
final Resource metadataResource = this.appRegistry.getAppMetadataResource(appRegistration);
if (metadataResource != null) {
final URLClassLoader classLoader = metadataResolver.createAppClassLoader(metadataResource);
this.doWithClassLoader(classLoader, () -> {
CompletionProposal.Factory proposals = expanding(dsl);
List<ConfigurationMetadataProperty> whiteList = metadataResolver.listProperties(metadataResource);
for (ConfigurationMetadataProperty property : metadataResolver.listProperties(metadataResource, true)) {
if (CompletionUtils.isMatchingProperty(propertyName, property, whiteList)) {
for (ValueHintProvider valueHintProvider : valueHintProviders) {
for (ValueHint valueHint : valueHintProvider.generateValueHints(property, classLoader)) {
collector.add(proposals.withSuffix(String.valueOf(valueHint.getValue()),
valueHint.getShortDescription()));
}
}
}
}
return null;
});
}
}
示例3: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) {
List<ValueHint> result = new ArrayList<>();
if (ClassUtils.isPresent(property.getType(), classLoader)) {
Class<?> clazz = ClassUtils.resolveClassName(property.getType(), classLoader);
if (clazz.isEnum()) {
for (Object o : clazz.getEnumConstants()) {
ValueHint hint = new ValueHint();
hint.setValue(o);
result.add(hint);
}
}
}
return result;
}
示例4: completePropValue
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
public void completePropValue(SpringBootService sbs, CompletionResultSet completionResultSet, String propName, String filter,
int startOffset, int caretOffset) {
long mark = System.currentTimeMillis();
logger.log(FINER, "Completing property value: {0}", filter);
for (ValueHint valueHint : sbs.queryHintMetadata(propName, filter)) {
completionResultSet.addItem(new CfgPropValueCompletionItem(valueHint, startOffset, caretOffset));
}
final long elapsed = System.currentTimeMillis() - mark;
logger.log(FINER, "Value completion of ''{0}'' on ''{1}'' took: {2} msecs", new Object[]{filter, propName, elapsed});
}
示例5: getText
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@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));
}
return sb.toString();
}
示例6: addAlreadyTypedValueHintsProposals
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
boolean addAlreadyTypedValueHintsProposals(final String text, AppRegistration appRegistration, final List<CompletionProposal> collector, final String propertyName, final ValueHintProvider[] valueHintProviders, final String alreadyTyped){
final Resource metadataResource = this.appRegistry.getAppMetadataResource(appRegistration);
if (metadataResource == null) {
return false;
}
final URLClassLoader classLoader = metadataResolver.createAppClassLoader(metadataResource);
return this.doWithClassLoader(classLoader, () -> {
CompletionProposal.Factory proposals = expanding(text);
List<ConfigurationMetadataProperty> allProps = metadataResolver.listProperties(metadataResource, true);
List<ConfigurationMetadataProperty> whiteListedProps = metadataResolver.listProperties(metadataResource);
for (ConfigurationMetadataProperty property : allProps) {
if (CompletionUtils.isMatchingProperty(propertyName, property, whiteListedProps)) {
for (ValueHintProvider valueHintProvider : valueHintProviders) {
List<ValueHint> valueHints = valueHintProvider.generateValueHints(property, classLoader);
if (!valueHints.isEmpty() && valueHintProvider.isExclusive(property)) {
collector.clear();
}
for (ValueHint valueHint : valueHints) {
String candidate = String.valueOf(valueHint.getValue());
if (!candidate.equals(alreadyTyped) && candidate.startsWith(alreadyTyped)) {
collector.add(proposals.withSuffix(candidate.substring(alreadyTyped.length()),
valueHint.getShortDescription()));
}
}
if (!valueHints.isEmpty() && valueHintProvider.isExclusive(property)) {
return true;
}
}
}
}
return false;
});
}
示例7: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) {
return property.getValueHints();
}
示例8: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) {
return "java.lang.Boolean".equals(property.getType())
? BOOLEANS
: Collections.<ValueHint>emptyList();
}
示例9: CfgPropValueCompletionItem
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
public CfgPropValueCompletionItem(ValueHint hint, int dotOffset, int caretOffset) {
this.hint = hint;
this.dotOffset = dotOffset;
this.caretOffset = caretOffset;
}
示例10: getHint
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
public ValueHint getHint() {
return hint;
}
示例11: getText
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@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 {
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();
}
示例12: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) {
return property.getHints().getValueHints();
}
示例13: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
@Override
public List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader) {
return "java.lang.Boolean".equals(property.getType()) ? BOOLEANS : Collections.<ValueHint>emptyList();
}
示例14: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
/**
* For a given property, return a list of {@link ValueHint} that may apply.
*
* @param property property for which to generate value hints
* @param classLoader class loader for the artifact/module that this
* property applies to; this may be used to load other classes/resources
* for generating value hints
* @return list of value hints for the provided property
*/
List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader);
示例15: generateValueHints
import org.springframework.boot.configurationmetadata.ValueHint; //导入依赖的package包/类
/**
* For a given property, return a list of {@link ValueHint} that may apply.
*
* @param property property for which to generate value hints
* @param classLoader class loader for the artifact/module that this property applies
* to; this may be used to load other classes/resources for generating value hints
* @return list of value hints for the provided property
*/
List<ValueHint> generateValueHints(ConfigurationMetadataProperty property, ClassLoader classLoader);