Record Class SyncResourceTemplateRegistration

java.lang.Object
java.lang.Record
org.springframework.ai.mcp.modern.SyncResourceTemplateRegistration
Record Components:
template - the definition returned by resources/templates/list, with the handler that completes its variables, if any
handler - the handler for resources/read of any URI matching the template

public record SyncResourceTemplateRegistration(io.modelcontextprotocol.modern.server.feature.McpSyncResourceTemplate template, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler) extends Record
A resource template together with the McpSyncResource that reads every URI matching it. See SyncResourceRegistration for why the pairing lives here: the SDK's McpSyncResourceTemplate carries the definition and the completion handler, but not the read handler.
Since:
2.1.0
Author:
Christian Tzolov
  • Constructor Summary

    Constructors
    Constructor
    Description
    SyncResourceTemplateRegistration(io.modelcontextprotocol.modern.server.feature.McpSyncResourceTemplate template, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler)
    Creates an instance of a SyncResourceTemplateRegistration record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    io.modelcontextprotocol.modern.server.feature.McpSyncResource
    Returns the value of the handler record component.
    final int
    Returns a hash code value for this object.
    of(io.modelcontextprotocol.modern.McpSchema.ResourceTemplate resourceTemplate, io.modelcontextprotocol.modern.McpSchema.ClientCapabilities requiredCapabilities, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
    Pairs a resource template with a handler that only works with clients declaring requiredCapabilities.
    of(io.modelcontextprotocol.modern.McpSchema.ResourceTemplate resourceTemplate, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
    Pairs a resource template with a handler that requires no client capabilities.
    io.modelcontextprotocol.modern.server.feature.McpSyncResourceTemplate
    Returns the value of the template record component.
    final String
    Returns a string representation of this record class.
    withCompletionHandler(io.modelcontextprotocol.modern.server.feature.McpSyncCompletionHandler completionHandler)
    This registration with the template's variables completed by completionHandler, when its repository supports completion.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SyncResourceTemplateRegistration

      public SyncResourceTemplateRegistration(io.modelcontextprotocol.modern.server.feature.McpSyncResourceTemplate template, io.modelcontextprotocol.modern.server.feature.McpSyncResource handler)
      Creates an instance of a SyncResourceTemplateRegistration record class.
      Parameters:
      template - the value for the template record component
      handler - the value for the handler record component
  • Method Details

    • of

      public static SyncResourceTemplateRegistration of(io.modelcontextprotocol.modern.McpSchema.ResourceTemplate resourceTemplate, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
      Pairs a resource template with a handler that requires no client capabilities.
      Since:
      2.1.0
    • of

      public static SyncResourceTemplateRegistration of(io.modelcontextprotocol.modern.McpSchema.ResourceTemplate resourceTemplate, io.modelcontextprotocol.modern.McpSchema.ClientCapabilities requiredCapabilities, io.modelcontextprotocol.modern.server.feature.McpSyncResource.Handler handler)
      Pairs a resource template with a handler that only works with clients declaring requiredCapabilities. A read from any other client is rejected with -32021 without running the handler.
      Since:
      2.1.0
    • withCompletionHandler

      public SyncResourceTemplateRegistration withCompletionHandler(io.modelcontextprotocol.modern.server.feature.McpSyncCompletionHandler completionHandler)
      This registration with the template's variables completed by completionHandler, when its repository supports completion.
      Since:
      2.1.0
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • template

      public io.modelcontextprotocol.modern.server.feature.McpSyncResourceTemplate template()
      Returns the value of the template record component.
      Returns:
      the value of the template record component
    • handler

      public io.modelcontextprotocol.modern.server.feature.McpSyncResource handler()
      Returns the value of the handler record component.
      Returns:
      the value of the handler record component