Record Class McpCompleteCompletion

java.lang.Object
java.lang.Record
com.github.codeboyzhou.mcp.declarative.server.component.McpCompleteCompletion
记录组件:
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.

作者:
codeboyzhou
  • 构造器详细资料

    • 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.

      参数:
      values - the input list of completion values to be defensively copied
  • 方法详细资料

    • 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.

      返回:
      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.

      返回:
      an empty McpCompleteCompletion instance
    • toString

      public final String toString()
      返回此记录的字符串表示形式。此表示形式包含类型的名称,后跟每个记录组件的名称和值。
      指定者:
      toString 在类中 Record
      返回:
      此对象的字符串表示形式
    • hashCode

      public final int hashCode()
      返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。
      指定者:
      hashCode 在类中 Record
      返回:
      此对象的哈希代码值
    • equals

      public final boolean equals(Object o)
      指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 使用 Objects::equals(Object,Object) 对参考组件进行比较;使用 '==' 对基元组件进行比较
      指定者:
      equals 在类中 Record
      参数:
      o - 要与之进行比较的对象
      返回:
      如果此对象与 o 参数相同,则为 true;否则为 false
    • values

      public List<String> values()
      返回 values 记录组件的值。
      返回:
      values 记录组件的值
    • total

      public Integer total()
      返回 total 记录组件的值。
      返回:
      total 记录组件的值
    • hasMore

      public boolean hasMore()
      返回 hasMore 记录组件的值。
      返回:
      hasMore 记录组件的值