Class CompositeRedactor

java.lang.Object
com.tnsai.quality.redaction.CompositeRedactor
All Implemented Interfaces:
Redactor

public final class CompositeRedactor extends Object implements Redactor
Pipes input through a chain of Redactors in order (issue #80). Each redactor's output text feeds the next, and findings concatenate across the chain.

Composition lets operators stack a fast-path PatternRedactor (catches credentials + structured PII) with a heavier LLM-classifier or Presidio bridge (catches names / addresses / health information that don't pattern-match cleanly) without either implementation knowing about the other.

Order matters: the first redactor's placeholders ([REDACTED:...]) pass through every later redactor unchanged, so a downstream LLM classifier doesn't get to "explain" what was already scrubbed.

Since:
0.5.0 (issue #80)
  • Constructor Details

    • CompositeRedactor

      public CompositeRedactor(List<Redactor> chain)
  • Method Details

    • of

      public static CompositeRedactor of(Redactor... redactors)
    • scrubString

      public RedactionResult scrubString(String input, RedactionContext ctx)
      Description copied from interface: Redactor
      Scrub sensitive patterns out of input, returning the redacted text + every match.
      Specified by:
      scrubString in interface Redactor
      Parameters:
      input - plaintext to scan; never null. "" is acceptable and returns an unchanged result.
      ctx - per-call context (sink, tenant policy)
      Returns:
      redacted text + findings; never null
    • maybeContainsSensitive

      public boolean maybeContainsSensitive(String input)
      Description copied from interface: Redactor
      Cheap pre-check: returns true when input might contain something worth scanning. Lets the framework short-circuit the regex loop on guaranteed-clean strings (UUIDs, numeric IDs, fixed-vocabulary enums). Default true because the safe fallback is "always scan"; override when you can do better.
      Specified by:
      maybeContainsSensitive in interface Redactor