Interface TextResourceContents

All Superinterfaces:
HasMeta, ResourceContents

@Immutable public non-sealed interface TextResourceContents extends ResourceContents
Text-based resource contents returned by a resource handler.

The uri identifies the originating resource, and text carries the actual content. mimeType should be set when the text has a specific format (e.g. application/json, text/markdown).

  • Method Details

    • uri

      @Parameter(order=1) String uri()
      Description copied from interface: ResourceContents
      Returns the resource URI.
      Specified by:
      uri in interface ResourceContents
      Returns:
      the resource identifier
    • mimeType

      @Parameter(order=2) @Nullable String mimeType()
      Description copied from interface: ResourceContents
      Returns the MIME type of the resource content, or null if unspecified.
      Specified by:
      mimeType in interface ResourceContents
      Returns:
      the MIME type, or null
    • text

      @Parameter(order=3) String text()
    • meta

      @Parameter(order=4) @Nullable Map<String,Object> meta()
      Description copied from interface: HasMeta
      Returns the optional metadata map for protocol extensions.
      Specified by:
      meta in interface HasMeta
      Returns:
      the metadata map, or null if none
    • check

      @Check default void check()
    • builder

      static TextResourceContents.Builder builder()
    • of

      static TextResourceContents of(String uri, String text, @Nullable String mimeType)
      Creates text resource contents with no _meta.
      Parameters:
      uri - the resource URI
      text - the text content
      mimeType - the content's MIME type, or null if unspecified
    • of

      static TextResourceContents of(String uri, String text, @Nullable String mimeType, @Nullable Map<String,Object> meta)
      Creates text resource contents.
      Parameters:
      uri - the resource URI
      text - the text content
      mimeType - the content's MIME type, or null if unspecified
      meta - the _meta entries, or null if none