Interface PropertyResolver

    • Method Detail

      • containsProperty

        boolean containsProperty​(String key)
        Whether the given property key is available.
        Returns:
        true if the given property key is available for resolution otherwise false.
      • getProperty

        String getProperty​(String key,
                           String defaultValue)
        Find the property value associated with the given key. If the associated property value not found, defaultValue will be returned.
        Parameters:
        key - the property name to resolve
        defaultValue - the default value to return if no value is found
        Returns:
        property value
        See Also:
        getRequiredProperty(String), getProperty(String, Function)
      • getProperty

        <R,​T> Optional<T> getProperty​(String key,
                                            Function<R,​T> mappingFunction)
        Find the property value associated with the given key. Optional.empty() will be returned if the key cannot be resolved.
        Parameters:
        key - the property name to resolve
        mappingFunction - the mapping function convert original object to target objet.
        Returns:
        property value
        See Also:
        getRequiredProperty(String, Function)
      • getProperty

        <R,​T> T getProperty​(String key,
                                  Function<R,​T> mappingFunction,
                                  T defaultValue)
        Find the property value associated with the given key. If the associated property value not found, defaultValue will be returned.
        Parameters:
        key - the property name to resolve
        mappingFunction - the mapping function convert original object to target objet
        defaultValue - the default value to return if no value is found
        Returns:
        property value
        See Also:
        getRequiredProperty(String, Function)
      • getRequiredProperty

        <R,​T> T getRequiredProperty​(String key,
                                          Function<R,​T> mappingFunction)
                                   throws IllegalStateException
        Find the property value associated with the given key (never null).
        Parameters:
        key - the property name to resolve
        mappingFunction - the mapping function convert original object to target objet
        Returns:
        property value
        Throws:
        IllegalStateException - if the given key cannot be resolved
      • resolveRequiredPlaceholders

        String resolveRequiredPlaceholders​(String text)
                                    throws IllegalArgumentException
        Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty(java.lang.String). Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.
        Returns:
        the resolved String (never null)
        Throws:
        IllegalArgumentException - if given text is null or if any placeholders are unresolvable
      • setPlaceholderPrefix

        void setPlaceholderPrefix​(String placeholderPrefix)
        Set the prefix that placeholders replaced by this resolver must begin with.
      • setPlaceholderSuffix

        void setPlaceholderSuffix​(String placeholderSuffix)
        Set the suffix that placeholders replaced by this resolver must end with.
      • setValueSeparator

        void setValueSeparator​(String valueSeparator)
        Specify the separating character between the placeholders replaced by this resolver and their associated default value, or null if no such special character should be processed as a value separator.