Class PropertiesUtils

  • All Implemented Interfaces:
    Utils

    public abstract class PropertiesUtils
    extends java.lang.Object
    implements Utils
    The utilities class for Properties
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> flatProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
      Flattens a nested map of properties into a single-level map.
      protected static void flatProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties, java.lang.String propertyNamePrefix, java.util.Map<java.lang.String,​java.lang.Object> flattenProperties)
      Recursively flattens the given properties map into a single-level map.
      • Methods inherited from class java.lang.Object

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

      • flatProperties

        @Nonnull
        @Immutable
        public static java.util.Map<java.lang.String,​java.lang.Object> flatProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties)
        Flattens a nested map of properties into a single-level map.

        If the input map is empty or null, the same map instance is returned.

        For example, given the following input:

        
         {
           "a": "1",
           "b": {
             "c": "2",
             "d": {
               "e": "3"
             }
           }
         }
         
        The resulting flattened map would be:
        
         {
           "a": "1",
           "b.c": "2",
           "b.d.e": "3"
         }
         
        Parameters:
        properties - The map containing potentially nested properties to be flattened.
        Returns:
        A new unmodifiable map with all properties flattened to a single level.
      • flatProperties

        protected static void flatProperties​(java.util.Map<java.lang.String,​java.lang.Object> properties,
                                             java.lang.String propertyNamePrefix,
                                             java.util.Map<java.lang.String,​java.lang.Object> flattenProperties)
        Recursively flattens the given properties map into a single-level map.
        Parameters:
        properties - The map containing properties to be flattened.
        propertyNamePrefix - The prefix for property names used during flattening.
        flattenProperties - The target map where flattened properties are stored.