Package io.prometheus.jmx.common.yaml
Class YamlMapAccessor
java.lang.Object
io.prometheus.jmx.common.yaml.YamlMapAccessor
Class to implement a MapAccessor to work with nested Maps / values
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPath
(String path) Method to determine if a path existsstatic YamlMapAccessor
empty()
Method to get a MapAccessor backed by an empty MapMethod to get a path ObjectgetOrCreate
(String path, Supplier<Object> supplier) Method to get a path Object or create an Object using the SuppliergetOrThrow
(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
-
Constructor Details
-
YamlMapAccessor
Constructor- Parameters:
map
- map
-
-
Method Details
-
containsPath
Method to determine if a path exists- Parameters:
path
- path- Returns:
- true if the path exists (but could be null), false otherwise
-
get
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
Method to get a path Object or create an Object using the Supplierparent paths will be created if required
- Parameters:
path
- pathsupplier
- supplier- Returns:
- an Optional containing the path Object or Optional created by the Supplier
-
getOrThrow
Method to get a path Object, throwing an RuntimeException created by the Supplier if the path doesn't exist- Parameters:
path
- pathsupplier
- supplier- Returns:
- an Optional containing the path Object
-
empty
Method to get a MapAccessor backed by an empty Map- Returns:
- the return value
-