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 * The end user's answer to an {@link ElicitRequest} (MCP {@code 2026-07-28} SEP-2322), echoed back keyed by the 028 * same server-assigned id in a follow-up request's {@code inputResponses} and decoded via 029 * {@code org.apache.juneau.rest.server.mcp.v20260728.ElicitationResponses}. 030 * 031 * <p> 032 * {@link #getContent()} is present only when {@link #getAction()} is {@link ElicitAction#ACCEPT}; its shape is 033 * whatever {@link ElicitRequest#getRequestedSchema()} described, which is per-elicitation and unknowable at the 034 * bean-definition level, so it is deliberately left an untyped, dynamic map. 035 */ 036@Marshalled 037public class ElicitResult { 038 039 private ElicitAction action; 040 private Map<String,Object> content; 041 042 /** 043 * The end user's choice. 044 * 045 * @return The action, or {@code null} if not set. 046 */ 047 public ElicitAction getAction() { 048 return action; 049 } 050 051 /** 052 * Sets the end user's choice. 053 * 054 * @param value The new value. Can be <jk>null</jk> to unset the property. 055 * @return This object (for method chaining). 056 */ 057 public ElicitResult setAction(ElicitAction value) { 058 action = value; 059 return this; 060 } 061 062 /** 063 * The schema-shaped answer content. Present only when {@link #getAction()} is {@link ElicitAction#ACCEPT}. 064 * 065 * @return The content map, or {@code null} if not set. 066 */ 067 public Map<String,Object> getContent() { 068 return u(content); 069 } 070 071 /** 072 * Sets the schema-shaped answer content. 073 * 074 * @param value The new value. Can be <jk>null</jk> to unset the property. 075 * @return This object (for method chaining). 076 */ 077 public ElicitResult setContent(Map<String,Object> value) { 078 content = value; 079 return this; 080 } 081 082 /** 083 * Convenience method to add a single content entry. 084 * 085 * @param name The entry name. Can be <jk>null</jk> ({@link LinkedHashMap} tolerates a <jk>null</jk> key). 086 * @param value The entry value. Can be <jk>null</jk> (stored as <jk>null</jk>). 087 * @return This object (for method chaining). 088 */ 089 public ElicitResult putContent(String name, Object value) { 090 if (content == null) 091 content = map(); 092 content.put(name, value); 093 return this; 094 } 095}