Class MapUtils

java.lang.Object
io.github.vitalforge.persistlib.util.MapUtils

public final class MapUtils extends Object
Utility class for operations on Maps.
  • Method Details

    • getDeepValue

      @Nullable public static @Nullable Object getDeepValue(Map<String,Object> map, String path)
      Retrieves a value from a nested map using a string path.
      Parameters:
      map - The map from which to retrieve the value.
      path - The path to the value in the map.
      Returns:
      The value at the specified path, or null if the path does not exist.
    • getDeepValue

      @Nullable public static <K> @Nullable Object getDeepValue(Map<K,Object> map, K[] path)
      Retrieves a value from a nested map using an array of keys.
      Type Parameters:
      K - The type of the keys in the map.
      Parameters:
      map - The map from which to retrieve the value.
      path - The path to the value in the map.
      Returns:
      The value at the specified path, or null if the path does not exist.
    • putDeepValue

      public static void putDeepValue(Map<String,Object> map, Object value, String path)
      Inserts a value into a map at a specified string path, creating nested maps as necessary.
      Parameters:
      map - The map into which to insert the value.
      value - The value to insert.
      path - The path at which to insert the value.
    • putDeepValue

      public static <K> void putDeepValue(Map<K,Object> map, Object value, K[] path)
      Inserts a value into a map at a specified path, creating nested maps as necessary.
      Type Parameters:
      K - The type of the keys in the map.
      Parameters:
      map - The map into which to insert the value.
      value - The value to insert.
      path - The path at which to insert the value.