1 2 /* 3 * Copyright (c) 2011-2022 PrimeFaces Extensions 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this software and associated documentation files (the "Software"), to deal 7 * in the Software without restriction, including without limitation the rights 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * copies of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 * THE SOFTWARE. 22 */ 23 24 package org.primefaces.extensions.model.monacoeditor; 25 26 import org.primefaces.shaded.json.*; 27 import java.io.ObjectStreamException; 28 import java.io.Serializable; 29 30 // ============================================================ 31 // THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT EDIT DIRECTLY. 32 // ============================================================ 33 34 /** 35 * Data that defines a custom theme for the Monaco code editor 36 */ 37 @SuppressWarnings("serial") 38 public class EditorStandaloneTheme extends JSONObject implements Serializable { 39 private Object writeReplace() throws ObjectStreamException { 40 return new SerializedEditorStandaloneTheme(this); 41 } 42 43 private static class SerializedEditorStandaloneTheme implements Serializable { 44 private String json; 45 46 public SerializedEditorStandaloneTheme(EditorStandaloneTheme editorStandaloneTheme) { 47 this.json = editorStandaloneTheme.toString(); 48 } 49 50 private Object readResolve() throws ObjectStreamException { 51 final EditorStandaloneTheme editorStandaloneTheme = new EditorStandaloneTheme(); 52 final JSONObject data = new JSONObject(json); 53 for (final String key : data.keySet()) { 54 final Object value = data.get(key); 55 editorStandaloneTheme.put(key, value); 56 } 57 return editorStandaloneTheme; 58 } 59 } 60 61 /** 62 * @return Base theme from which to extend when {@inherit} is set to {@code true}. This is required, when not set it 63 * defaults to {@code vs}. 64 */ 65 public String getBase() { 66 return (String) (has("base") ? get("base") : null); 67 } 68 69 /** 70 * @param base Base theme from which to extend when {@inherit} is set to {@code true}. This is required, when not 71 * set it defaults to {@code vs}. 72 * @return This same instance, useful for chaining multiple setter methods in one call. 73 */ 74 public EditorStandaloneTheme setBase(final ETheme base) { 75 put("base", base != null ? base.toString() : null); 76 return this; 77 } 78 79 /** 80 * @param base Base theme from which to extend when {@inherit} is set to {@code true}. This is required, when not 81 * set it defaults to {@code vs}. 82 * @return This same instance, useful for chaining multiple setter methods in one call. 83 */ 84 public EditorStandaloneTheme setBase(final String base) { 85 put("base", base); 86 return this; 87 } 88 89 /** 90 * @return Map between the color ID and the CSS color to use. This is required, when not set, it defaults to an 91 * empty map. 92 */ 93 public JSONObject getColors() { 94 return (JSONObject) (has("colors") ? get("colors") : null); 95 } 96 97 /** 98 * @param colors Map between the color ID and the CSS color to use. This is required, when not set, it defaults to 99 * an empty map. 100 * @return This same instance, useful for chaining multiple setter methods in one call. 101 */ 102 public EditorStandaloneTheme setColors(final JSONObject colors) { 103 put("colors", colors); 104 return this; 105 } 106 107 /** 108 * Map between the color ID and the CSS color to use. This is required, when not set, it defaults to an empty map. 109 * @param key The key of the map entry to add. 110 * @param value The value to associate with the key. 111 * @return This same instance, useful for chaining multiple setter methods in one call. 112 */ 113 public EditorStandaloneTheme addColor(final String key, final String value) { 114 JSONObject x = getColors(); 115 if (x == null) { 116 x = new JSONObject(); 117 setColors(x); 118 } 119 x.put(key, value); 120 return this; 121 } 122 123 /** 124 * @param colors Map between the color ID and the CSS color to use. This is required, when not set, it defaults to 125 * an empty map. 126 * @return This same instance, useful for chaining multiple setter methods in one call. 127 */ 128 public EditorStandaloneTheme setColors(final java.util.Map<String, String> colors) { 129 return setColors(new JSONObject(colors)); 130 } 131 132 /** 133 * @return Optional list of encoded token colors. 134 */ 135 public JSONArray getEncodedTokensColors() { 136 return (JSONArray) (has("encodedTokensColors") ? get("encodedTokensColors") : null); 137 } 138 139 /** 140 * @param encodedTokensColors Optional list of encoded token colors. 141 * @return This same instance, useful for chaining multiple setter methods in one call. 142 */ 143 public EditorStandaloneTheme setEncodedTokensColors(final JSONArray encodedTokensColors) { 144 put("encodedTokensColors", encodedTokensColors); 145 return this; 146 } 147 148 /** 149 * @return Optional list of encoded token colors. 150 */ 151 public EditorStandaloneTheme addEncodedTokensColor(final String ... items) { 152 JSONArray x = getEncodedTokensColors(); 153 if (x == null) { 154 x = new JSONArray(); 155 setEncodedTokensColors(x); 156 } 157 for (String item : items) x.put(item); 158 return this; 159 } 160 161 /** 162 * @param encodedTokensColors Optional list of encoded token colors. 163 * @return This same instance, useful for chaining multiple setter methods in one call. 164 */ 165 public EditorStandaloneTheme setEncodedTokensColors(final java.util.List<String> encodedTokensColors) { 166 return setEncodedTokensColors(new JSONArray(encodedTokensColors)); 167 } 168 169 /** 170 * @return Whether this theme should inherit from the given base theme. This is required, when not set it defaults 171 * to {@code false}. 172 */ 173 public Boolean isInherit() { 174 return (Boolean) (has("inherit") ? get("inherit") : null); 175 } 176 177 /** 178 * @param inherit Whether this theme should inherit from the given base theme. This is required, when not set it 179 * defaults to {@code false}. 180 * @return This same instance, useful for chaining multiple setter methods in one call. 181 */ 182 public EditorStandaloneTheme setInherit(final Boolean inherit) { 183 put("inherit", inherit); 184 return this; 185 } 186 187 /** 188 * @return Styling options for individual token types, such as how to style variables, certain keywords, and 189 * parentheses. This is required, when not set it defaults to an empty array. 190 */ 191 public JSONArray getRules() { 192 return (JSONArray) (has("rules") ? get("rules") : null); 193 } 194 195 /** 196 * @param rules Styling options for individual token types, such as how to style variables, certain keywords, and 197 * parentheses. This is required, when not set it defaults to an empty array. 198 * @return This same instance, useful for chaining multiple setter methods in one call. 199 */ 200 public EditorStandaloneTheme setRules(final JSONArray rules) { 201 put("rules", rules); 202 return this; 203 } 204 205 /** 206 * @return Styling options for individual token types, such as how to style variables, certain keywords, and 207 * parentheses. This is required, when not set it defaults to an empty array. 208 */ 209 public EditorStandaloneTheme addRule(final EditorTokenThemeRule ... items) { 210 JSONArray x = getRules(); 211 if (x == null) { 212 x = new JSONArray(); 213 setRules(x); 214 } 215 for (EditorTokenThemeRule item : items) x.put(item); 216 return this; 217 } 218 219 /** 220 * @param rules Styling options for individual token types, such as how to style variables, certain keywords, and 221 * parentheses. This is required, when not set it defaults to an empty array. 222 * @return This same instance, useful for chaining multiple setter methods in one call. 223 */ 224 public EditorStandaloneTheme setRules(final java.util.List<EditorTokenThemeRule> rules) { 225 return setRules(new JSONArray(rules)); 226 } 227 228 /** 229 * @return This options object as a serializable JSON object 230 */ 231 JSONObject getJSONObject() { 232 return this; 233 } 234 }