Class CommandSupport

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

public final class CommandSupport extends Object
Shared static infrastructure used by two or more Command implementations.

This utility class centralises provider loading, scan orchestration, AI suggestion resolution, content hashing, and other cross-cutting concerns. All methods are static; this class cannot be instantiated.

Methods marked public (requireUniqueDiscoveryIds(java.util.List<org.egothor.methodatlas.api.TestDiscovery>), requireUniquePatcherIds(java.util.List<org.egothor.methodatlas.api.SourcePatcher>), computeFilePrefix(java.util.List<java.nio.file.Path>), buildAiEngine(org.egothor.methodatlas.ai.AiOptions), buildAiCache(java.nio.file.Path), and loadClassificationOverride(java.nio.file.Path)) are called either by MethodAtlasApp (a different package) or directly by unit tests; all other methods are package-private and intended for use within the org.egothor.methodatlas.command package only.

  • Method Details

    • buildAiEngine

      public static AiSuggestionEngine buildAiEngine(AiOptions aiOptions)
      Creates the AI suggestion engine for the current run.

      Returns null when AI support is disabled. Initialization failures are wrapped in an IllegalStateException.

      Parameters:
      aiOptions - AI configuration for the current run
      Returns:
      initialized AI suggestion engine, or null when AI is disabled
      Throws:
      IllegalStateException - if engine initialization fails
    • buildAiCache

      public static AiResultCache buildAiCache(Path cacheFile)
      Loads the AI result cache from the given CSV file, or returns the empty no-op cache when no cache file is configured.
      Parameters:
      cacheFile - path to a previous MethodAtlas CSV output, or null
      Returns:
      loaded cache; never null
      Throws:
      IllegalArgumentException - if the file exists but cannot be read or parsed
    • loadClassificationOverride

      public static ClassificationOverride loadClassificationOverride(Path overrideFile)
      Loads the classification override file, or returns the empty no-op singleton when no override file is configured.
      Parameters:
      overrideFile - path to the YAML override file, or null
      Returns:
      loaded override set; never null
      Throws:
      IllegalArgumentException - if the file exists but cannot be read or contains invalid YAML
    • requireUniqueDiscoveryIds

      public static void requireUniqueDiscoveryIds(List<org.egothor.methodatlas.api.TestDiscovery> providers)
      Verifies that every TestDiscovery provider in the list has a unique TestDiscovery.pluginId().
      Parameters:
      providers - list of configured providers
      Throws:
      IllegalStateException - if two or more providers share the same ID
    • requireUniquePatcherIds

      public static void requireUniquePatcherIds(List<org.egothor.methodatlas.api.SourcePatcher> patchers)
      Verifies that every SourcePatcher in the list has a unique SourcePatcher.pluginId().
      Parameters:
      patchers - list of configured patchers
      Throws:
      IllegalStateException - if two or more patchers share the same ID
    • computeFilePrefix

      public static String computeFilePrefix(List<Path> roots)
      Derives the file path prefix used in GitHub Actions workflow command annotations from the first configured scan root.

      The prefix is made relative to the current working directory so that the resulting annotation paths (e.g. src/test/java/com/acme/AuthTest.java) match what GitHub resolves as inline positions in the PR diff.

      Parameters:
      roots - configured scan roots; may be empty
      Returns:
      forward-slash path ending with /, or empty string when roots is empty