Record Class McpCompleteCompletion

java.lang.Object
java.lang.Record
com.github.thought2code.mcp.annotated.server.component.McpCompleteCompletion
Record Components:
values - the list of completion values, may be null
total - the total number of available completions, may be null
hasMore - true if more completions are available, false otherwise

public record McpCompleteCompletion(List<String> values, Integer total, boolean hasMore) extends Record
Represents a completion result for MCP (Model Context Protocol) server operations.

This record encapsulates the response data for completion requests, including the list of completion values, total count, and whether more results are available. The class is designed to be immutable and provides defensive copying to protect internal state from external modification.

Author:
codeboyzhou
  • Constructor Details

    • McpCompleteCompletion

      public McpCompleteCompletion(List<String> values, Integer total, boolean hasMore)
      Compact constructor that creates a defensive copy of the values list.

      This constructor ensures that the internal list cannot be modified from outside the record by creating an immutable copy using List.copyOf(Collection). If the input list is null, it remains null to preserve the original intent.

      Parameters:
      values - the input list of completion values to be defensively copied
      total - the total number of available completions, may be null
      hasMore - true if more completions are available, false otherwise
  • Method Details

    • builder

      public static McpCompleteCompletion.Builder builder()
      Creates a new McpCompleteCompletion.Builder instance for constructing McpCompleteCompletion objects.

      This factory method provides a convenient way to create a builder for step-by-step construction of completion results using the builder pattern.

      Returns:
      a new McpCompleteCompletion.Builder instance
    • empty

      public static McpCompleteCompletion empty()
      Creates an empty McpCompleteCompletion instance.

      This factory method returns a completion result with no values, zero total count, and no more results available. Useful as a default or placeholder completion.

      Returns:
      an empty McpCompleteCompletion instance
    • 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 '=='.
      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.
    • values

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

      public Integer total()
      Returns the value of the total record component.
      Returns:
      the value of the total record component
    • hasMore

      public boolean hasMore()
      Returns the value of the hasMore record component.
      Returns:
      the value of the hasMore record component