Class TableRowMatcher

java.lang.Object
org.openrewrite.toml.TableRowMatcher

public class TableRowMatcher extends Object
Utility methods for matching table rows and extracting values from TOML tables.
  • Method Details

    • getKeyValue

      public static @Nullable String getKeyValue(Toml.Table table, String key)
      Extracts the string value of a specific key from a TOML table.
      Parameters:
      table - The TOML table to search
      key - The key name to find
      Returns:
      The string value of the key, or null if not found or not a literal
    • getKeyValue

      public static @Nullable String getKeyValue(List<? extends Toml> keyValues, String key)
      Extracts the string value of a specific key from a list of TOML elements.
      Parameters:
      keyValues - The list of key-value pairs to search
      key - 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 search
      key - The key name to match
      value - 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