Record Class QuestionAndAnswer

java.lang.Object
java.lang.Record
org.ek9lang.assist.QuestionAndAnswer
Record Components:
id - Unique question identifier (e.g., 1, 2, 3)
category - Category name (e.g., "Getting Started")
question - The canonical question text
alternatePhrasings - Alternative ways to ask the same question
answer - The answer text (may contain markdown formatting)
ek9Example - Inline EK9 code example or file reference
migrationContext - Which developer backgrounds find this relevant
keywords - Pre-tokenized keywords for matching (no stop words)

public record QuestionAndAnswer(int id, String category, String question, List<String> alternatePhrasings, String answer, String ek9Example, String migrationContext, Set<String> keywords) extends Record
Holds a single Q&A entry for the EK9 knowledge base. Used by the -q CLI for developer queries and -Q for training data export.
  • Constructor Details

    • QuestionAndAnswer

      public QuestionAndAnswer(int id, String category, String question, List<String> alternatePhrasings, String answer, String ek9Example, String migrationContext, Set<String> keywords)
      Creates an instance of a QuestionAndAnswer record class.
      Parameters:
      id - the value for the id record component
      category - the value for the category record component
      question - the value for the question record component
      alternatePhrasings - the value for the alternatePhrasings record component
      answer - the value for the answer record component
      ek9Example - the value for the ek9Example record component
      migrationContext - the value for the migrationContext record component
      keywords - the value for the keywords record component
  • Method Details

    • searchableTokens

      public Set<String> searchableTokens()
      All searchable tokens: keywords plus tokenized alternate phrasings and migration context. Keywords are the primary match source; alternates and migration context broaden discovery so that tool-specific queries like "maven" or "mvn" find relevant answers.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public int id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • category

      public String category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • question

      public String question()
      Returns the value of the question record component.
      Returns:
      the value of the question record component
    • alternatePhrasings

      public List<String> alternatePhrasings()
      Returns the value of the alternatePhrasings record component.
      Returns:
      the value of the alternatePhrasings record component
    • answer

      public String answer()
      Returns the value of the answer record component.
      Returns:
      the value of the answer record component
    • ek9Example

      public String ek9Example()
      Returns the value of the ek9Example record component.
      Returns:
      the value of the ek9Example record component
    • migrationContext

      public String migrationContext()
      Returns the value of the migrationContext record component.
      Returns:
      the value of the migrationContext record component
    • keywords

      public Set<String> keywords()
      Returns the value of the keywords record component.
      Returns:
      the value of the keywords record component