org.springframework.boot.configurationmetadata.ValueHint#setValue ( )源码实例Demo

下面列出了org.springframework.boot.configurationmetadata.ValueHint#setValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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;
}
 
@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;
}
 
源代码3 项目: nb-springboot   文件: Utils.java
/**
 * Create a {@code ValueHint} object from the given value and description.
 *
 * @param value the value to use
 * @param description the description to use
 * @return a ValueHint object
 */
public static ValueHint createHint(String value, String description) {
    ValueHint vh = new ValueHint();
    vh.setValue(value);
    vh.setDescription(description);
    return vh;
}
 
源代码4 项目: nb-springboot   文件: Utils.java
/**
 * Create a {@code ValueHint} object from the given value.
 * <p>
 * Created hint has no description.
 *
 * @param value the value to use
 * @return a ValueHint object
 */
public static ValueHint createHint(String value) {
    ValueHint vh = new ValueHint();
    vh.setValue(value);
    return vh;
}
 
源代码5 项目: nb-springboot   文件: Utils.java
/**
 * Create a {@code ValueHint} object from the given java enumeration value.
 * <p>
 * Created hint has no description and has a Spring Boot property name canonical format.
 *
 * @param value the value to use
 * @return a ValueHint object
 */
public static ValueHint createEnumHint(String value) {
    ValueHint vh = new ValueHint();
    vh.setValue(value.replaceAll("_", "-"));
    return vh;
}