Class FallbackConfigurationHelper


  • public class FallbackConfigurationHelper
    extends java.lang.Object
    Substitutes property formats list with provided variables values and returns first not empty value of substituted configuration property key. Variables which can be used in property format are {{extension}}, {{group}} and {{property}} for example "{{extension}}.{{group}}.{{property}}".
    • Constructor Summary

      Constructors 
      Constructor Description
      FallbackConfigurationHelper​(java.util.List<java.lang.String> propertyFormats, ConfigurationService configurationService)
      Creates a new fallback configuration helper with given list of property formats and configuration service.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.String> getFirstValue​(java.lang.String extension, java.lang.String group, java.lang.String attribute)
      Gets value of first not empty value of substituted configuration property key from property formats list.
      <T> java.util.Optional<T> getFirstValue​(java.lang.String extension, java.lang.String group, java.lang.String attribute, java.util.function.Function<java.lang.String,​T> valueMapper)
      Gets value of first not empty value of substituted configuration property key from property formats list.
      <T> java.util.Optional<T> getFirstValue​(java.util.Map<java.lang.String,​java.lang.String> substitutions, java.util.function.Function<java.lang.String,​T> valueMapper)
      Gets value of first not empty value of substituted configuration property from property formats list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FallbackConfigurationHelper

        public FallbackConfigurationHelper​(java.util.List<java.lang.String> propertyFormats,
                                           ConfigurationService configurationService)
        Creates a new fallback configuration helper with given list of property formats and configuration service.
        Parameters:
        propertyFormats - list of property formats
        configurationService - configuration service
    • Method Detail

      • getFirstValue

        public java.util.Optional<java.lang.String> getFirstValue​(java.lang.String extension,
                                                                  java.lang.String group,
                                                                  java.lang.String attribute)
        Gets value of first not empty value of substituted configuration property key from property formats list.
        Parameters:
        extension - extension name of property
        group - group name of property
        attribute - attribute name of property
        Returns:
        first not empty value of substituted property key
      • getFirstValue

        public <T> java.util.Optional<T> getFirstValue​(java.lang.String extension,
                                                       java.lang.String group,
                                                       java.lang.String attribute,
                                                       java.util.function.Function<java.lang.String,​T> valueMapper)
        Gets value of first not empty value of substituted configuration property key from property formats list. Method internally maps returned String value using provider mapper.
        Type Parameters:
        T - the Object type to be returned
        Parameters:
        extension - extension name of configuration property key
        group - group name of configuration property key
        attribute - attribute name of configuration property key
        valueMapper - mapper which maps configuration property value
        Returns:
        first not empty value of substituted configuration property key
      • getFirstValue

        public <T> java.util.Optional<T> getFirstValue​(java.util.Map<java.lang.String,​java.lang.String> substitutions,
                                                       java.util.function.Function<java.lang.String,​T> valueMapper)
        Gets value of first not empty value of substituted configuration property from property formats list. Method internally maps returned String value using provider mapper.
        Type Parameters:
        T - the Object type to be returned
        Parameters:
        substitutions - map of String substitutions
        valueMapper - mapper which maps property value
        Returns:
        value of resolved property