Package org.openrewrite.toml
Class TableRowMatcher
java.lang.Object
org.openrewrite.toml.TableRowMatcher
Utility methods for matching table rows and extracting values from TOML tables.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringgetKeyValue(List<? extends Toml> keyValues, String key) Extracts the string value of a specific key from a list of TOML elements.static @Nullable StringgetKeyValue(Toml.Table table, String key) Extracts the string value of a specific key from a TOML table.static booleanhasMatchingKeyValue(Toml.Table table, String key, String value, @Nullable Boolean useRegex) Checks if a TOML table contains a key-value pair that matches the specified criteria.
-
Method Details
-
getKeyValue
Extracts the string value of a specific key from a TOML table.- Parameters:
table- The TOML table to searchkey- The key name to find- Returns:
- The string value of the key, or null if not found or not a literal
-
getKeyValue
Extracts the string value of a specific key from a list of TOML elements.- Parameters:
keyValues- The list of key-value pairs to searchkey- The key name to find- Returns:
- The string value of the key, or null if not found or not a literal
-
hasMatchingKeyValue
public static boolean hasMatchingKeyValue(Toml.Table table, String key, String value, @Nullable Boolean useRegex) Checks if a TOML table contains a key-value pair that matches the specified criteria.- Parameters:
table- The TOML table to searchkey- The key name to matchvalue- The value to match (exact match or regex pattern)useRegex- Whether to interpret the value as a regular expression- Returns:
- true if a matching key-value pair is found, false otherwise
-