Class RegexCensorElement

java.lang.Object
com.easypost.easyvcr.CensorElement
com.easypost.easyvcr.RegexCensorElement

public class RegexCensorElement extends CensorElement
  • Constructor Details

    • RegexCensorElement

      public RegexCensorElement(String pattern, boolean caseSensitive)
      Constructor.
      Parameters:
      pattern - The regular expression pattern of the element to censor.
      caseSensitive - Whether the pattern is case sensitive.
  • Method Details

    • matchAndReplaceAsNeeded

      public String matchAndReplaceAsNeeded(String value, String replacement)
      Replace the provided value with the provided replacement if the value matches the pattern.
      Parameters:
      value - Value to apply the replacement to.
      replacement - Replacement for a detected matching section.
      Returns:
      The replacement if the value matches the pattern, otherwise the original value.
    • matches

      public boolean matches(String key)
      Return whether the provided element matches the name, accounting for case sensitivity.
      Overrides:
      matches in class CensorElement
      Parameters:
      key - The value to check.
      Returns:
      True if the element matches the pattern.