Java Code Examples for org.springframework.boot.configurationmetadata.ValueHint#setValue()

The following examples show how to use org.springframework.boot.configurationmetadata.ValueHint#setValue() . 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: EnumValueHintProvider.java    From spring-cloud-dashboard with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 2
Source File: EnumValueHintProvider.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 3
Source File: Utils.java    From nb-springboot with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: Utils.java    From nb-springboot with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: Utils.java    From nb-springboot with Apache License 2.0 2 votes vote down vote up
/**
 * 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;
}