Class SuggestionLookup

java.lang.Object
org.egothor.methodatlas.ai.SuggestionLookup

public final class SuggestionLookup extends Object
Immutable lookup structure providing efficient access to AI-generated method suggestions by method name.

This class acts as an adapter between the class-level suggestion model returned by the AI subsystem (AiClassSuggestion) and the per-method processing logic used by MethodAtlasApp. It converts the list of AiMethodSuggestion objects into a name-indexed lookup map so that suggestions can be retrieved in constant time during traversal of parsed test methods.

Design Characteristics

  • immutable after construction
  • null-safe for missing or malformed AI responses
  • optimized for repeated method-level lookups

If the AI response contains duplicate suggestions for the same method, only the first occurrence is retained.

See Also:
  • Method Details

    • from

      public static SuggestionLookup from(AiClassSuggestion suggestion)
      Creates a lookup instance from a class-level AI suggestion result.

      The method extracts all method suggestions contained in the supplied AiClassSuggestion and indexes them by method name. Entries with null suggestions, missing method names, or blank method names are ignored.

      If the suggestion contains no method entries, an empty lookup instance is returned.

      Parameters:
      suggestion - AI classification result for a test class
      Returns:
      lookup structure providing fast access to method suggestions
    • find

      public Optional<AiMethodSuggestion> find(String methodName)
      Retrieves the AI suggestion for the specified method name.

      If no suggestion exists for the method, an empty Optional is returned.

      Parameters:
      methodName - name of the method being queried
      Returns:
      optional containing the suggestion if present
      Throws:
      NullPointerException - if methodName is null