001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.server.mcp.v20260728; 018 019import org.apache.juneau.bean.mcp.v20260728.McpCacheScope; 020 021/** 022 * A single {@code ttlMs}/{@code cacheScope} configuration pair applied to a v2 cacheable result. 023 * 024 * <p> 025 * Both fields are nullable. A {@code null} {@link #getTtlMs()} means no TTL hint is emitted on the wire. 026 * A {@code null} {@link #getCacheScope()} means the wire omits {@code cacheScope} entirely, which per 027 * SEP-2549 is equivalent to {@code "public"} (public-by-absence). 028 */ 029public class McpCacheHint { 030 031 private Integer ttlMs; 032 private McpCacheScope cacheScope; 033 034 /** 035 * The cache TTL in milliseconds. 036 * 037 * @return The TTL, or {@code null} if no TTL hint is configured. 038 */ 039 public Integer getTtlMs() { 040 return ttlMs; 041 } 042 043 /** 044 * Sets the cache TTL in milliseconds. 045 * 046 * @param value The new value. Can be {@code null} to unset the property. Must not be negative. 047 * @return This object. 048 * @throws IllegalArgumentException If {@code value} is negative. 049 */ 050 public McpCacheHint setTtlMs(Integer value) { 051 if (value != null && value < 0) 052 throw new IllegalArgumentException("ttlMs " + value + " is below minimum 0"); 053 ttlMs = value; 054 return this; 055 } 056 057 /** 058 * The cache scope. 059 * 060 * @return The scope, or {@code null} if not set (public-by-absence). 061 */ 062 public McpCacheScope getCacheScope() { 063 return cacheScope; 064 } 065 066 /** 067 * Sets the cache scope. 068 * 069 * @param value The new value. Can be {@code null} to unset the property (public-by-absence). 070 * @return This object. 071 */ 072 public McpCacheHint setCacheScope(McpCacheScope value) { 073 cacheScope = value; 074 return this; 075 } 076}