Class PromptNormalizer

java.lang.Object
org.mockserver.llm.PromptNormalizer

public final class PromptNormalizer extends Object
Deterministic normalisation of LLM prompt text prior to conversation-predicate matching. Pure and side-effect-free: the same input plus options always yields the same output, so normalised matching never makes a test flaky.

When the input parses as JSON, structural operations (key sorting, field dropping) are applied to the parsed tree; otherwise the input is treated as plain text. The text path never throws — any parse failure falls back to text-only normalisation.

See Also:
  • Method Details

    • normalize

      public static String normalize(String text, NormalizationOptions options)
      Normalise text according to options. A null options (or null text) returns the input unchanged.
      Parameters:
      text - the prompt text to normalise (may be null)
      options - the normalisation options (may be null)
      Returns:
      the normalised text, never throwing