public class DefaultPropertyPlaceholderResolver extends java.lang.Object implements PropertyPlaceholderResolver
PropertyPlaceholderResolver
.Modifier and Type | Class and Description |
---|---|
class |
DefaultPropertyPlaceholderResolver.PlaceholderSegment
A segment that represents one or more expressions
that should be searched for in the environment.
|
class |
DefaultPropertyPlaceholderResolver.RawSegment
A segment that represents static text.
|
static interface |
DefaultPropertyPlaceholderResolver.Segment
A segment of placeholder resolution.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PREFIX
Prefix for placeholder in properties.
|
static java.lang.String |
SUFFIX
Suffix for placeholder in properties.
|
Constructor and Description |
---|
DefaultPropertyPlaceholderResolver(PropertyResolver environment,
ConversionService conversionService) |
Modifier and Type | Method and Description |
---|---|
java.util.List<DefaultPropertyPlaceholderResolver.Segment> |
buildSegments(java.lang.String str)
Split a placeholder value into logic segments.
|
java.lang.String |
getPrefix() |
protected <T> T |
resolveExpression(java.lang.String context,
java.lang.String expression,
java.lang.Class<T> type)
Resolves a single expression.
|
java.util.Optional<java.lang.String> |
resolvePlaceholders(java.lang.String str)
Resolve the placeholders and return an Optional String if it was possible to resolve them.
|
<T> T |
resolveRequiredPlaceholder(java.lang.String str,
java.lang.Class<T> type)
Resolves the value of a single placeholder.
|
java.lang.String |
resolveRequiredPlaceholders(java.lang.String str)
Resolve the placeholders and return an Optional String if it was possible to resolve them.
|
public static final java.lang.String PREFIX
public static final java.lang.String SUFFIX
public DefaultPropertyPlaceholderResolver(PropertyResolver environment, ConversionService conversionService)
environment
- The property resolver for the environmentconversionService
- The conversion servicepublic java.lang.String getPrefix()
getPrefix
in interface PropertyPlaceholderResolver
public java.util.Optional<java.lang.String> resolvePlaceholders(java.lang.String str)
PropertyPlaceholderResolver
resolvePlaceholders
in interface PropertyPlaceholderResolver
str
- The placeholder to resolveOptional.empty()
if resolution was not possiblepublic java.lang.String resolveRequiredPlaceholders(java.lang.String str) throws ConfigurationException
PropertyPlaceholderResolver
resolveRequiredPlaceholders
in interface PropertyPlaceholderResolver
str
- The placeholder to resolveOptional.empty()
if resolution was not possibleConfigurationException
- If the placeholders could not be resolvedpublic <T> T resolveRequiredPlaceholder(java.lang.String str, java.lang.Class<T> type) throws ConfigurationException
PropertyPlaceholderResolver
resolveRequiredPlaceholder
in interface PropertyPlaceholderResolver
T
- The type the value should be converted tostr
- The string containing the placeholdertype
- The class of the typeConfigurationException
- If multiple placeholders are found or
if the placeholder could not be converted to the requested typepublic java.util.List<DefaultPropertyPlaceholderResolver.Segment> buildSegments(java.lang.String str)
str
- The placeholder@Nullable protected <T> T resolveExpression(java.lang.String context, java.lang.String expression, java.lang.Class<T> type)
T
- The type the expression should be converted tocontext
- The context of the expressionexpression
- The expressiontype
- The class