Class YamlMapAccessor

java.lang.Object
io.prometheus.jmx.common.yaml.YamlMapAccessor

public class YamlMapAccessor extends Object
Class to implement a MapAccessor to work with nested Maps / values
  • Constructor Details

  • Method Details

    • containsPath

      public boolean containsPath(String path)
      Method to determine if a path exists
      Parameters:
      path - path
      Returns:
      true if the path exists (but could be null), false otherwise
    • get

      public Optional<Object> get(String path)
      Method to get a path Object
      Parameters:
      path - path
      Returns:
      an Optional containing the path Object or an empty Optional if the path doesn't exist
    • getOrCreate

      public Optional<Object> getOrCreate(String path, Supplier<Object> supplier)
      Method to get a path Object or create an Object using the Supplier

      parent paths will be created if required

      Parameters:
      path - path
      supplier - supplier
      Returns:
      an Optional containing the path Object or Optional created by the Supplier
    • getOrThrow

      public Optional<Object> getOrThrow(String path, Supplier<? extends RuntimeException> supplier)
      Method to get a path Object, throwing an RuntimeException created by the Supplier if the path doesn't exist
      Parameters:
      path - path
      supplier - supplier
      Returns:
      an Optional containing the path Object
    • empty

      public static YamlMapAccessor empty()
      Method to get a MapAccessor backed by an empty Map
      Returns:
      the return value