001package Torello.JSON; 002 003import Torello.JavaDoc.Annotations.StaticFunctional; 004import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 005import Torello.JavaDoc.Annotations.LinkJavaSource; 006import Torello.JavaDoc.Annotations.IntoHTMLTable; 007 008import static Torello.JavaDoc.Annotations.IntoHTMLTable.Background.GreenDither; 009import static Torello.JavaDoc.Annotations.IntoHTMLTable.Background.BlueDither; 010 011import Torello.Java.Function.IntIntTConsumer; 012import Torello.Java.Function.IntIntTFunc; 013 014import javax.json.Json; 015import javax.json.JsonArray; 016import javax.json.JsonString; 017import javax.json.JsonObject; 018 019import java.util.function.Consumer; 020import java.util.function.Function; 021 022/** 023 * Utilities for parsing Json Array's and sending the parsed values into a Java Consumer 024 * Functional-Interface. 025 * 026 * <EMBED CLASS='external-html' DATA-FILE-ID=ALL_CLASSES_NOTE> 027 * <EMBED CLASS='external-html' DATA-FILE-ID=RJA_CONS_REC> 028 * <EMBED CLASS='external-html' DATA-FILE-ID=JO_DESERIALIZE> 029 * <EMBED CLASS='external-html' DATA-FILE-ID=LOOP_OPTIMIZED_NOTE> 030 * <EMBED CLASS='external-html' DATA-FILE-ID=RJ_PT_CONS_REC> 031 * 032 * @see Json 033 * @see JsonArray 034 */ 035@StaticFunctional 036@JDHeaderBackgroundImg(EmbedTagFileID="RJA_JDHBI_CONS_REC") 037public class RJArrConsumerRec 038{ 039 private RJArrConsumerRec() { } 040 041 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 // Buid a SettingsRec<T, Void> Instance for sending an Object 'T' to a Consumer<T> 045 // ******************************************************************************************** 046 // ******************************************************************************************** 047 048 049 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ1_CONS1_REC> */ 050 @LinkJavaSource(handle="EXTENDED_TYPES", name="FROM_CTOR") 051 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 052 @IntoHTMLTable( 053 background=GreenDither, 054 title= 055 "Build a SettingsRec<T, Void> instance; " + 056 "Record asks instances of Parameterized-Type <T> be sent to a Consumer<T>" 057 ) 058 public static <T> SettingsRec<T, Void> objRec( 059 final T defaultValue, 060 final int FLAGS, 061 final Class<T> consumerClass 062 ) 063 { 064 return new SETTINGS_REC_BUILDER<T, Void> 065 (defaultValue, FLAGS, null, EXTENDED_TYPES.FROM_CTOR(consumerClass)) 066 .updateableConsumer(true); 067 } 068 069 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ2_CONS1_REC> */ 070 @LinkJavaSource(handle="EXTENDED_TYPES", name="ONE_ARG_FUNC") 071 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 072 @IntoHTMLTable( 073 background=BlueDither, 074 title= 075 "Build a SettingsRec<T, Void> instance; " + 076 "Record asks instances of Parameterized-Type <T> be sent to a Consumer<T>" 077 ) 078 public static <T> SettingsRec<T, Void> objRec( 079 final T defaultValue, 080 final int FLAGS, 081 final Function<JsonObject, T> objBuilder, 082 final Class<T> consumerClass 083 ) 084 { 085 return new SETTINGS_REC_BUILDER<T, Void> 086 (defaultValue, FLAGS, null, EXTENDED_TYPES.ONE_ARG_FUNC(objBuilder, consumerClass)) 087 .updateableConsumer(true); 088 } 089 090 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ3_CONS1_REC> */ 091 @LinkJavaSource(handle="EXTENDED_TYPES", name="THREE_ARG_FUNC") 092 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 093 @IntoHTMLTable( 094 background=GreenDither, 095 title= 096 "Build a SettingsRec<T, Void> instance; " + 097 "Record asks instances of Parameterized-Type <T> be sent to a Consumer<T>" 098 ) 099 public static <T> SettingsRec<T, Void> objRec( 100 final T defaultValue, 101 final int FLAGS, 102 final IntIntTFunc<JsonObject, T> objBuilder, 103 final Class<T> consumerClass 104 ) 105 { 106 return new SETTINGS_REC_BUILDER<T, Void> 107 (defaultValue, FLAGS, null, EXTENDED_TYPES.THREE_ARG_FUNC(objBuilder, consumerClass)) 108 .updateableConsumer(true); 109 } 110 111 112 // ******************************************************************************************** 113 // ******************************************************************************************** 114 // Build a SettingsRec<T, Void> instance for sending an Object 'T' to an IntIntTConsumer<T> 115 // ******************************************************************************************** 116 // ******************************************************************************************** 117 118 119 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ1_CONS2_REC> */ 120 @LinkJavaSource(handle="EXTENDED_TYPES", name="FROM_CTOR") 121 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 122 @IntoHTMLTable( 123 background=BlueDither, 124 title= 125 "Build a SettingsRec<T, Void> instance; " + 126 "Record asks instances of Parameterized-Type <T> be sent to an " + 127 "IntIntTConsumer<T>" 128 ) 129 public static <T> SettingsRec<T, Void> objRec2( 130 final T defaultValue, 131 final int FLAGS, 132 final Class<T> consumerClass 133 ) 134 { 135 return new SETTINGS_REC_BUILDER<T, Void> 136 (defaultValue, FLAGS, null, EXTENDED_TYPES.FROM_CTOR(consumerClass)) 137 .updateableConsumer(false); 138 } 139 140 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ2_CONS2_REC> */ 141 @LinkJavaSource(handle="EXTENDED_TYPES", name="ONE_ARG_FUNC") 142 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 143 @IntoHTMLTable( 144 background=GreenDither, 145 title= 146 "Build a SettingsRec<T, Void> instance; " + 147 "Record asks instances of Parameterized-Type <T> be sent to an " + 148 "IntIntTConsumer<T>" 149 ) 150 public static <T> SettingsRec<T, Void> objRec2( 151 final T defaultValue, 152 final int FLAGS, 153 final Function<JsonObject, T> objBuilder, 154 final Class<T> consumerClass 155 ) 156 { 157 return new SETTINGS_REC_BUILDER<T, Void> 158 (defaultValue, FLAGS, null, EXTENDED_TYPES.ONE_ARG_FUNC(objBuilder, consumerClass)) 159 .updateableConsumer(false); 160 } 161 162 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_OBJ3_CONS2_REC> */ 163 @LinkJavaSource(handle="EXTENDED_TYPES", name="THREE_ARG_FUNC") 164 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 165 @IntoHTMLTable( 166 background=BlueDither, 167 title= 168 "Build a SettingsRec<T, Void> instance; " + 169 "Record asks instances of Parameterized-Type <T> be sent to an " + 170 "IntIntTConsumer<T>" 171 ) 172 public static <T> SettingsRec<T, Void> objRec2( 173 final T defaultValue, 174 final int FLAGS, 175 final IntIntTFunc<JsonObject, T> objBuilder, 176 final Class<T> consumerClass 177 ) 178 { 179 return new SETTINGS_REC_BUILDER<T, Void> 180 (defaultValue, FLAGS, null, EXTENDED_TYPES.THREE_ARG_FUNC(objBuilder, consumerClass)) 181 .updateableConsumer(false); 182 } 183 184 185 // ******************************************************************************************** 186 // ******************************************************************************************** 187 // Build a SettingsRec<String, Void> Instance. 188 // ******************************************************************************************** 189 // ******************************************************************************************** 190 191 192 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_STR_CONS1_REC> */ 193 @LinkJavaSource(handle="BASIC_TYPES", name="STRING_REC") 194 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 195 @IntoHTMLTable( 196 background=GreenDither, 197 title= 198 "Build a SettingsRec<String, Void> instance; " + 199 "Record asks String's be sent to a Consumer<String>" 200 ) 201 public static SettingsRec<String, Void> strRec( 202 final String defaultValue, 203 final int FLAGS 204 ) 205 { 206 return new SETTINGS_REC_BUILDER<String, Void> 207 (defaultValue, FLAGS, null, BASIC_TYPES.STRING_REC()) 208 .updateableConsumer(true); 209 } 210 211 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_STR_CONS2_REC> */ 212 @LinkJavaSource(handle="BASIC_TYPES", name="STRING_REC") 213 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 214 @IntoHTMLTable( 215 background=BlueDither, 216 title= 217 "Build a SettingsRec<String, Void> instance; " + 218 "Record asks String's be sent to an IntIntTConsumer<String>" 219 ) 220 public static SettingsRec<String, Void> strRec2( 221 final String defaultValue, 222 final int FLAGS 223 ) 224 { 225 return new SETTINGS_REC_BUILDER<String, Void> 226 (defaultValue, FLAGS, null, BASIC_TYPES.STRING_REC()) 227 .updateableConsumer(false); 228 } 229 230 231 // ******************************************************************************************** 232 // ******************************************************************************************** 233 // Build a SettingsRec<JsonObject, Void> Instance 234 // ******************************************************************************************** 235 // ******************************************************************************************** 236 237 238 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_JO_CONS1_REC> */ 239 @LinkJavaSource(handle="BASIC_TYPES", name="JSON_OBJECT_REC") 240 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 241 @IntoHTMLTable( 242 background=GreenDither, 243 title= 244 "Build a SettingsRec<JsonObject, Void> instance; " + 245 "Record asks JsonObject's be sent to a Consumer<JsonObject>" 246 ) 247 public static SettingsRec<JsonObject, Void> joRec( 248 final JsonObject defaultValue, 249 final int FLAGS 250 ) 251 { 252 return new SETTINGS_REC_BUILDER<JsonObject, Void> 253 (defaultValue, FLAGS, null, BASIC_TYPES.JSON_OBJECT_REC()) 254 .updateableConsumer(true); 255 } 256 257 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_JO_CONS2_REC> */ 258 @LinkJavaSource(handle="BASIC_TYPES", name="JSON_OBJECT_REC") 259 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 260 @IntoHTMLTable( 261 background=BlueDither, 262 title= 263 "Build a SettingsRec<JsonObject, Void> instance; " + 264 "Record asks JsonObject's be sent to an IntIntTConsumer<JsonObject>" 265 ) 266 public static SettingsRec<JsonObject, Void> joRec2( 267 final JsonObject defaultValue, 268 final int FLAGS 269 ) 270 { 271 return new SETTINGS_REC_BUILDER<JsonObject, Void> 272 (defaultValue, FLAGS, null, BASIC_TYPES.JSON_OBJECT_REC()) 273 .updateableConsumer(false); 274 } 275 276 277 // ******************************************************************************************** 278 // ******************************************************************************************** 279 // Build a SettingsRec<JsonArray, Void> Instance 280 // ******************************************************************************************** 281 // ******************************************************************************************** 282 283 284 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_JA_CONS1_REC> */ 285 @LinkJavaSource(handle="BASIC_TYPES", name="JSON_ARRAY_REC") 286 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 287 @IntoHTMLTable( 288 background=GreenDither, 289 title= 290 "Build a SettingsRec<JsonArray, Void> instance; " + 291 "Record asks JsonArray's be sent to a Consumer<JsonArray>" 292 ) 293 public static SettingsRec<JsonArray, Void> jaRec( 294 final JsonArray defaultValue, 295 final int FLAGS 296 ) 297 { 298 return new SETTINGS_REC_BUILDER<JsonArray, Void> 299 (defaultValue, FLAGS, null, BASIC_TYPES.JSON_ARRAY_REC()) 300 .updateableConsumer(true); 301 } 302 303 /** <EMBED CLASS='external-html' DATA-FILE-ID=RJ_ARR_JA_CONS2_REC> */ 304 @LinkJavaSource(handle="BASIC_TYPES", name="JSON_ARRAY_REC") 305 @LinkJavaSource(handle="SETTINGS_REC_BUILDER", name="updateableConsumer") 306 @IntoHTMLTable( 307 background=BlueDither, 308 title= 309 "Build a SettingsRec<JsonArray, Void> instance; " + 310 "Record asks JsonArray's be sent to an IntIntTConsumer<JsonArray>" 311 ) 312 public static SettingsRec<JsonArray, Void> jaRec2( 313 final JsonArray defaultValue, 314 final int FLAGS 315 ) 316 { 317 return new SETTINGS_REC_BUILDER<JsonArray, Void> 318 (defaultValue, FLAGS, null, BASIC_TYPES.JSON_ARRAY_REC()) 319 .updateableConsumer(false); 320 } 321 322}