Class CommentRedaction

java.lang.Object
org.egothor.methodatlas.command.CommentRedaction

public final class CommentRedaction extends Object
Applies the loaded CommentRedactors to source text on its way to an AI provider, failing closed.

The first redactor whose CommentRedactor.supports(Path) accepts the file performs the redaction. If none does, or the redactor reports it cannot guarantee redaction, RedactionAbortedException is thrown so that no un-redacted source can leave the process.

Instances are immutable; thread safety is that of the wrapped redactors.

Since:
4.1.0
See Also:
  • Constructor Details

    • CommentRedaction

      public CommentRedaction(List<org.egothor.methodatlas.api.CommentRedactor> redactors)
      Creates a service over the given redactors.
      Parameters:
      redactors - redactors in priority order; must not be null
  • Method Details

    • none

      public static CommentRedaction none()
      Returns a service with no redactors, which rejects every file.
      Returns:
      a new empty instance; never null
    • redactOrThrow

      public String redactOrThrow(Path file, String source)
      Returns source with comments blanked by the redactor responsible for file.
      Parameters:
      file - the file the text came from; null is treated as an unknown language and rejected
      source - full source text; must not be null
      Returns:
      redacted text, same length and line structure as source
      Throws:
      RedactionAbortedException - if no redactor supports the file or the redactor fails