Interface ConfigurablePropertyResolver
- All Superinterfaces:
PropertyResolver
- All Known Subinterfaces:
ConfigurableEnvironment, ConfigurableWebEnvironment
- All Known Implementing Classes:
AbstractEnvironment, AbstractPropertyResolver, MockEnvironment, PropertySourcesPropertyResolver, StandardEnvironment, StandardServletEnvironment
Configuration interface to be implemented by most if not all
PropertyResolver
types. Provides facilities for accessing and customizing the
ConversionService
used when converting property values from one type to another.- Since:
- 3.1
- Author:
- Chris Beams, Stephane Nicoll
-
Method Summary
Modifier and TypeMethodDescriptionReturn theConfigurableConversionServiceused when performing type conversions on properties.voidsetConversionService(ConfigurableConversionService conversionService) Set theConfigurableConversionServiceto be used when performing type conversions on properties.voidsetEscapeCharacter(@Nullable Character escapeCharacter) Set the escape character to use to ignore the placeholder prefix and the value separator, ornullif no escaping should take place.voidsetIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) Specify whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property.voidsetPlaceholderPrefix(String placeholderPrefix) Set the prefix that placeholders replaced by this resolver must begin with.voidsetPlaceholderSuffix(String placeholderSuffix) Set the suffix that placeholders replaced by this resolver must end with.voidsetRequiredProperties(String... requiredProperties) Specify which properties must be present, to be verified byvalidateRequiredProperties().voidsetValueSeparator(@Nullable String valueSeparator) Set the separating character to be honored between placeholders replaced by this resolver and their associated default values, ornullif no such special character should be processed as a value separator.voidValidate that each of the properties specified bysetRequiredProperties(String...)is present and resolves to a non-nullvalue.Methods inherited from interface PropertyResolver
containsProperty, getProperty, getProperty, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders
-
Method Details
-
getConversionService
ConfigurableConversionService getConversionService()Return theConfigurableConversionServiceused when performing type conversions on properties.The configurable nature of the returned conversion service allows for the convenient addition and removal of individual
Converterinstances:ConfigurableConversionService cs = env.getConversionService(); cs.addConverter(new FooConverter());
- See Also:
-
setConversionService
Set theConfigurableConversionServiceto be used when performing type conversions on properties.Note: as an alternative to fully replacing the
ConversionService, consider adding or removing individualConverterinstances by drilling intogetConversionService()and calling methods such as#addConverter.- See Also:
-
setPlaceholderPrefix
Set the prefix that placeholders replaced by this resolver must begin with. -
setPlaceholderSuffix
Set the suffix that placeholders replaced by this resolver must end with. -
setValueSeparator
-
setEscapeCharacter
Set the escape character to use to ignore the placeholder prefix and the value separator, ornullif no escaping should take place.- Since:
- 6.2
-
setIgnoreUnresolvableNestedPlaceholders
void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders) Specify whether to throw an exception when encountering an unresolvable placeholder nested within the value of a given property. Afalsevalue indicates strict resolution, i.e. that an exception will be thrown. Atruevalue indicates that unresolvable nested placeholders should be passed through in their unresolved ${...} form.Implementations of
PropertyResolver.getProperty(String)and its variants must inspect the value set here to determine correct behavior when property values contain unresolvable placeholders.- Since:
- 3.2
-
setRequiredProperties
Specify which properties must be present, to be verified byvalidateRequiredProperties(). -
validateRequiredProperties
Validate that each of the properties specified bysetRequiredProperties(String...)is present and resolves to a non-nullvalue.- Throws:
MissingRequiredPropertiesException- if any of the required properties are not resolvable
-