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 icon descriptor (the schema's {@code Icons.icons} entry shape), used by {@link Implementation}. 028 */ 029@Marshalled 030public class Icon { 031 032 private String src; 033 private String mimeType; 034 private List<String> sizes; 035 private Theme theme; 036 037 /** 038 * Icon source location (typically a URI). 039 * 040 * <p> 041 * Required by the schema; not validated by this DTO. 042 * 043 * @return The source, or {@code null} if not set. 044 */ 045 public String getSrc() { 046 return src; 047 } 048 049 /** 050 * Sets the icon source location. 051 * 052 * @param value The new value. Can be <jk>null</jk> to unset the property. 053 * @return This object (for method chaining). 054 */ 055 public Icon setSrc(String value) { 056 src = value; 057 return this; 058 } 059 060 /** 061 * Icon MIME type. 062 * 063 * @return The MIME type, or {@code null} if not set. 064 */ 065 public String getMimeType() { 066 return mimeType; 067 } 068 069 /** 070 * Sets the icon MIME type. 071 * 072 * @param value The new value. Can be <jk>null</jk> to unset the property. 073 * @return This object (for method chaining). 074 */ 075 public Icon setMimeType(String value) { 076 mimeType = value; 077 return this; 078 } 079 080 /** 081 * Ordered list of available sizes (for example {@code "48x48"} or {@code "any"}). 082 * 083 * @return The sizes list, or {@code null} if not set. 084 */ 085 public List<String> getSizes() { 086 return u(sizes); 087 } 088 089 /** 090 * Sets the ordered list of available sizes. 091 * 092 * @param value The new value. Can be <jk>null</jk> to unset the property. 093 * @return This object (for method chaining). 094 */ 095 public Icon setSizes(List<String> value) { 096 sizes = value; 097 return this; 098 } 099 100 /** 101 * Sets the ordered list of available sizes. 102 * 103 * @param value The new value. Can be <jk>null</jk> to unset the property. 104 * @return This object (for method chaining). 105 */ 106 public Icon setSizes(String...value) { 107 sizes = list(value); 108 return this; 109 } 110 111 /** 112 * Appends to the ordered list of available sizes. 113 * 114 * @param value The values to append. 115 * @return This object (for method chaining). 116 */ 117 public Icon addSizes(String...value) { 118 if (sizes == null) 119 sizes = list(); 120 Collections.addAll(sizes, value); 121 return this; 122 } 123 124 /** 125 * Appends to the ordered list of available sizes. 126 * 127 * @param value The values to append. 128 * @return This object (for method chaining). 129 */ 130 public Icon addSizes(Collection<String> value) { 131 if (sizes == null) 132 sizes = list(); 133 sizes.addAll(value); 134 return this; 135 } 136 137 /** 138 * Color-scheme theme this icon is suited for. 139 * 140 * @return The theme, or {@code null} if not set. 141 */ 142 public Theme getTheme() { 143 return theme; 144 } 145 146 /** 147 * Sets the color-scheme theme. 148 * 149 * @param value The new value. Can be <jk>null</jk> to unset the property. 150 * @return This object (for method chaining). 151 */ 152 public Icon setTheme(Theme value) { 153 theme = value; 154 return this; 155 } 156 157 /** 158 * Icon color-scheme hint, restricted to the schema's two legal values (MCP wire uses lowercase strings). 159 */ 160 public enum Theme { 161 162 /** Icon is suited for light backgrounds. */ 163 LIGHT("light"), 164 165 /** Icon is suited for dark backgrounds. */ 166 DARK("dark"); 167 168 private final String wire; 169 170 Theme(String wire) { 171 this.wire = wire; 172 } 173 174 /** 175 * Wire token for JSON payloads. 176 * 177 * @return Lowercase MCP icon-theme string. 178 */ 179 public String toWire() { 180 return wire; 181 } 182 183 @Override /* Object */ 184 public String toString() { 185 return wire; 186 } 187 } 188}