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.bean.mcp.v20260728; 018 019import static org.apache.juneau.commons.utils.CollectionUtils.*; 020import static org.apache.juneau.commons.utils.Shorts.*; 021 022import java.util.*; 023 024import org.apache.juneau.marshall.*; 025 026/** 027 * MCP client capability advertisement carried by RequestMeta. 028 */ 029@Marshalled 030public class ClientCapabilities { 031 032 private RootsCapability roots; 033 private ElicitationCapability elicitation; 034 private SamplingCapability sampling; 035 private Map<String,Object> experimental; 036 private Map<String,Object> extensions; 037 038 /** 039 * Roots capability. 040 * 041 * @return The capability, or {@code null} if not set. 042 */ 043 public RootsCapability getRoots() { 044 return roots; 045 } 046 047 /** 048 * Sets roots capability. 049 * 050 * @param value The new value. Can be <jk>null</jk> to unset the property. 051 * @return This object (for method chaining). 052 */ 053 public ClientCapabilities setRoots(RootsCapability value) { 054 roots = value; 055 return this; 056 } 057 058 /** 059 * Elicitation capability. 060 * 061 * @return The capability, or {@code null} if not set. 062 */ 063 public ElicitationCapability getElicitation() { 064 return elicitation; 065 } 066 067 /** 068 * Sets elicitation capability. 069 * 070 * @param value The new value. Can be <jk>null</jk> to unset the property. 071 * @return This object (for method chaining). 072 */ 073 public ClientCapabilities setElicitation(ElicitationCapability value) { 074 elicitation = value; 075 return this; 076 } 077 078 /** 079 * Sampling capability. 080 * 081 * @return The capability, or {@code null} if not set. 082 */ 083 public SamplingCapability getSampling() { 084 return sampling; 085 } 086 087 /** 088 * Sets sampling capability. 089 * 090 * @param value The new value. Can be <jk>null</jk> to unset the property. 091 * @return This object (for method chaining). 092 */ 093 public ClientCapabilities setSampling(SamplingCapability value) { 094 sampling = value; 095 return this; 096 } 097 098 /** 099 * Experimental capability extensions. 100 * 101 * @return The experimental map, or {@code null} if not set. 102 */ 103 public Map<String,Object> getExperimental() { 104 return u(experimental); 105 } 106 107 /** 108 * Sets experimental extensions. 109 * 110 * @param value The new value. Can be <jk>null</jk> to unset the property. 111 * @return This object (for method chaining). 112 */ 113 public ClientCapabilities setExperimental(Map<String,Object> value) { 114 experimental = value; 115 return this; 116 } 117 118 /** 119 * Convenience method to add a single experimental extension entry. 120 * 121 * @param name The extension name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 122 * @param value The extension value. Can be <jk>null</jk> (stored as <jk>null</jk>). 123 * @return This object (for method chaining). 124 */ 125 public ClientCapabilities putExperimental(String name, Object value) { 126 if (experimental == null) 127 experimental = map(); 128 experimental.put(name, value); 129 return this; 130 } 131 132 /** 133 * Schema-defined capability extensions (distinct from the free-form {@code experimental} bag). 134 * 135 * @return The extensions map, or {@code null} if not set. 136 */ 137 public Map<String,Object> getExtensions() { 138 return u(extensions); 139 } 140 141 /** 142 * Sets capability extensions. 143 * 144 * @param value The new value. Can be <jk>null</jk> to unset the property. 145 * @return This object (for method chaining). 146 */ 147 public ClientCapabilities setExtensions(Map<String,Object> value) { 148 extensions = value; 149 return this; 150 } 151 152 /** 153 * Convenience method to add a single capability extension entry. 154 * 155 * <p> 156 * The extension map is lazily initialized on first use and preserves insertion order across repeated calls. 157 * 158 * @param name The extension name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 159 * @param value The extension value. Can be <jk>null</jk> (stored as <jk>null</jk>). 160 * @return This object (for method chaining). 161 */ 162 public ClientCapabilities putExtensions(String name, Object value) { 163 if (extensions == null) 164 extensions = map(); 165 extensions.put(name, value); 166 return this; 167 } 168}