Package io.micronaut.context.env
Interface PropertyPlaceholderResolver
- All Known Subinterfaces:
ApplicationContext,ConfigurableApplicationContext
- All Known Implementing Classes:
DefaultPropertyPlaceholderResolver
public interface PropertyPlaceholderResolver
Interface for implementations that resolve placeholders in configuration and annotations.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull Stringdefault <T> Optional<T> resolveOptionalPlaceholder(String str, Class<T> type) Resolves the optional value of a single placeholder.Resolve the placeholders and return an Optional String if it was possible to resolve them.default <T> @NonNull TresolveRequiredPlaceholder(String str, Class<T> type) Resolves the value of a single placeholder.default @NonNull StringResolve the placeholders and return a string if it was possible to resolve them.default @NonNull ObjectResolve the placeholders in the given string.
-
Method Details
-
resolvePlaceholders
Resolve the placeholders and return an Optional String if it was possible to resolve them.- Parameters:
str- The placeholder to resolve- Returns:
- The optional string or
Optional.empty()if resolution was not possible
-
getPrefix
- Returns:
- The prefix used
-
resolveRequiredPlaceholders
Resolve the placeholders and return a string if it was possible to resolve them.- Parameters:
str- The placeholder to resolve- Returns:
- The resolved string
- Throws:
ConfigurationException- If the placeholders could not be resolved
-
resolveRequiredPlaceholdersObject
Resolve the placeholders in the given string. This behaves likeresolveRequiredPlaceholders(String), except that when the whole input is a placeholder, the value is not converted to String but returned as-is.- Parameters:
str- The placeholder to resolve- Returns:
- The resolved object or string
- Throws:
ConfigurationException- If the placeholders could not be resolved
-
resolveRequiredPlaceholder
default <T> @NonNull T resolveRequiredPlaceholder(String str, Class<T> type) throws ConfigurationException Resolves the value of a single placeholder.- Type Parameters:
T- The type the value should be converted to- Parameters:
str- The string containing the placeholdertype- The class of the type- Returns:
- The resolved value
- Throws:
ConfigurationException- If multiple placeholders are found or if the placeholder could not be converted to the requested type
-
resolveOptionalPlaceholder
default <T> Optional<T> resolveOptionalPlaceholder(String str, Class<T> type) throws ConfigurationException Resolves the optional value of a single placeholder.- Type Parameters:
T- The type the value should be converted to- Parameters:
str- The string containing the placeholdertype- The class of the type- Returns:
- The resolved optional value
- Throws:
ConfigurationException- Since:
- 4.2.0
-