Class CacheableResult<T extends CacheableResult<T>>

java.lang.Object
org.apache.juneau.bean.mcp.v20260728.Result<T>
org.apache.juneau.bean.mcp.v20260728.CacheableResult<T>
Type Parameters:
T - The concrete subclass, for fluent-setter self-typing.
Direct Known Subclasses:
ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ListToolsResult, ReadResourceResult, ServerDiscoverResult

public abstract class CacheableResult<T extends CacheableResult<T>> extends Result<T>
Shared SEP-2549 cache-hint base for the five cacheable 2026-07-28 result carriers (tools/list, prompts/list, resources/list, resources/templates/list, and resources/read).

Extends Result so every cacheable result also inherits the required resultType discriminator and optional _meta, alongside two nullable, independent, top-level cache-hint properties that are peers of each subclass's own payload properties:

  • ttlMs - Freshness duration in milliseconds (Cache-Control: max-age semantics). 0 means immediately stale.
  • cacheScope - McpCacheScope.PUBLIC or McpCacheScope.PRIVATE. An absent value is interpreted by consumers as public, but that interpretation is never materialized on the wire.

This base is a lossless wire carrier only: it performs no ttlMs validation and does not synthesize a default cacheScope. Wire beans must be able to parse and round-trip arbitrary protocol payloads (including a negative parsed ttlMs) independently of any server-side configuration policy. TTL validation for values the server itself emits is owned by the 2026-07-28 adapter's cache configuration, not by this bean.

The CRTP type parameter lets each concrete subclass's cache setters (and the inherited Result setters) return its own concrete type for fluent chaining, without duplicating those accessors in every subclass.

  • Constructor Details

  • Method Details

    • getTtlMs

      public Integer getTtlMs()
      Cache freshness duration in milliseconds.
      Returns:
      The TTL, or null if not set.
    • setTtlMs

      public T setTtlMs(Integer value)
      Sets the cache freshness duration in milliseconds.
      Parameters:
      value - The new value. Can be null to unset the property. 0 is a valid, meaningful value meaning immediately stale.
      Returns:
      This object (for method chaining).
    • getCacheScope

      Cache-hint authorization scope.
      Returns:
      The scope, or null if not set.
    • setCacheScope

      public T setCacheScope(McpCacheScope value)
      Sets the cache-hint authorization scope.
      Parameters:
      value - The new value. Can be null to unset the property.
      Returns:
      This object (for method chaining).