Package ru.bgcrm.util

Class ParameterMap

All Implemented Interfaces:
Map<String,String>
Direct Known Subclasses:
Preferences

public abstract class ParameterMap extends AbstractMap<String,String>
Key - value strings map.
  • Field Details

    • configMap

      protected volatile ConcurrentHashMap<Class<?>,Config> configMap
      Конфигурации, разбираются при первом обращении и кешируются далее.
    • EMPTY

      public static ParameterMap EMPTY
    • mapPrint

      protected String mapPrint
  • Constructor Details

    • ParameterMap

      public ParameterMap()
  • Method Details

    • of

      public static ParameterMap of(Object... keyValues)
      Creates ParameterMap object from key values pairs.
      Parameters:
      keyValues - key1, value1,... String.valueOf() is applied to each argument.
      Returns:
    • get

      public abstract String get(String key, String def)
    • get

      public String get(Object key)
      Specified by:
      get in interface Map<String,String>
      Overrides:
      get in class AbstractMap<String,String>
    • getSok

      public String getSok(String def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSok

      public String getSok(String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      keys - first key is the actual one, after - olds.
      Returns:
    • getInt

      public int getInt(String key, int def)
    • getInt

      public int getInt(String key)
    • getLong

      public long getLong(String key, long def)
    • getLong

      public long getLong(String key)
    • getSokLong

      public long getSokLong(long def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSokLong

      public long getSokLong(long def, String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getBoolean

      public final boolean getBoolean(String key, boolean defaultValue)
    • getSokBoolean

      public boolean getSokBoolean(boolean def, boolean validate, String... keys) throws BGMessageException
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      validate - throw an exception on using old keys.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getSokBoolean

      public boolean getSokBoolean(boolean def, String... keys)
      Retrieves by key value with support of old keys.
      Parameters:
      def - default value.
      keys - first key is the actual one, after - olds.
      Returns:
      Throws:
      BGMessageException
    • getBigDecimal

      public BigDecimal getBigDecimal(String key, BigDecimal def)
    • entrySet

      public abstract Set<Map.Entry<String,String>> entrySet()
      Specified by:
      entrySet in interface Map<String,String>
      Specified by:
      entrySet in class AbstractMap<String,String>
    • fingerprint

      @Deprecated public String fingerprint()
      Deprecated.
    • sub

      public ParameterMap sub(String... prefixes)
      Selects subset of parameters by key prefixes.
      Parameters:
      prefixes - key prefixes.
      Returns:
    • getDataString

      public String getDataString()
      Сериализация набора параметров в строку <ключ>=<значение> с переносами строк.
      Returns:
    • getDataString

      public String getDataString(String prefix)
      Сериализация набора параметров в строку <ключ>=<значение> с переносами строк. К каждой строке добавляется префикс.
      Parameters:
      prefix -
      Returns:
    • getDataString

      @Deprecated public static final String getDataString(ParameterMap config)
      Deprecated.
    • subIndexed

      public SortedMap<Integer,ParameterMap> subIndexed(String... prefixes)
      Creates a new sorted sub-map with integer keys.
       prefix.1.12=2
       prefix.1.34=4
       prefix.2.56=2
       prefix.2.78=4
       ->
       sorted Map
       1={12=2,34=4}
       2={56=2,78=4}
      Parameters:
      prefixes - prefixes for extraction.
      Returns:
      never null.
      See Also:
      • #subKeyed(String)
    • subKeyed

      public Map<String,ParameterMap> subKeyed(String... prefixies)
      Creates a new unsorted sub-map with integer keys.
       prefix.a.12=2
       prefix.a.34=4
       prefix.b.56=2
       prefix.b.78=4
       ->
       unsorted map
       a={12=2,34=4}
       b={56=2,78=4}
      Parameters:
      prefixes - prefixes for extraction.
      Returns:
      never null.
      See Also:
      • #subIndexed(String)
    • parseObjectsNoOrder

      @Deprecated public Map<String,Map<String,String>> parseObjectsNoOrder(String prefix)
      Deprecated.
      Parameters:
      prefix -
      Returns:
    • getConfig

      public final <K extends Config> K getConfig(Class<K> clazz)
      Creates if needed and gets pre parsed and cached configuration. Cache key - the class object of the configuration.
      Parameters:
      clazz -
      Returns:
    • getConfig

      public final Object getConfig(String className)
      Same with getConfig(Class), but with string parameter for calling from JSP and JEXL.
      Parameters:
      className -
      Returns:
    • removeConfig

      public <K extends Config> void removeConfig(Class<K> clazz)
      Removes config from cache.
      Type Parameters:
      K -
      Parameters:
      clazz -
    • validateConfig

      public final <K extends Config> void validateConfig(Class<K> clazz) throws BGMessageException
      Creates a configuration for validation purposes only..
      Parameters:
      clazz -
      Throws:
      BGMessageException