Class DefaultPropertyPlaceholderResolver

    • Field Detail

      • PREFIX

        public static final java.lang.String PREFIX
        Prefix for placeholder in properties.
        See Also:
        Constant Field Values
      • SUFFIX

        public static final java.lang.String SUFFIX
        Suffix for placeholder in properties.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultPropertyPlaceholderResolver

        public DefaultPropertyPlaceholderResolver​(io.micronaut.core.value.PropertyResolver environment,
                                                  io.micronaut.core.convert.ConversionService conversionService)
        Parameters:
        environment - The property resolver for the environment
        conversionService - The conversion service
    • Method Detail

      • resolvePlaceholders

        public java.util.Optional<java.lang.String> resolvePlaceholders​(java.lang.String str)
        Description copied from interface: PropertyPlaceholderResolver
        Resolve the placeholders and return an Optional String if it was possible to resolve them.
        Specified by:
        resolvePlaceholders in interface PropertyPlaceholderResolver
        Parameters:
        str - The placeholder to resolve
        Returns:
        The optional string or Optional.empty() if resolution was not possible
      • resolveRequiredPlaceholder

        public <T> T resolveRequiredPlaceholder​(java.lang.String str,
                                                java.lang.Class<T> type)
                                         throws ConfigurationException
        Description copied from interface: PropertyPlaceholderResolver
        Resolves the value of a single placeholder.
        Specified by:
        resolveRequiredPlaceholder in interface PropertyPlaceholderResolver
        Type Parameters:
        T - The type the value should be converted to
        Parameters:
        str - The string containing the placeholder
        type - 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
      • buildSegments

        public java.util.List<DefaultPropertyPlaceholderResolver.Segment> buildSegments​(java.lang.String str)
        Split a placeholder value into logic segments.
        Parameters:
        str - The placeholder
        Returns:
        The list of segments
      • resolveExpression

        @Nullable
        protected <T> T resolveExpression​(java.lang.String context,
                                          java.lang.String expression,
                                          java.lang.Class<T> type)
        Resolves a single expression.
        Type Parameters:
        T - The type the expression should be converted to
        Parameters:
        context - The context of the expression
        expression - The expression
        type - The class
        Returns:
        The resolved and converted expression
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception