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.marshall.marshaller;
018
019import static org.apache.juneau.commons.utils.ThrowableUtils.*;
020
021import java.io.*;
022import java.lang.reflect.*;
023import java.util.*;
024
025import org.apache.juneau.marshall.parser.*;
026import org.apache.juneau.marshall.serializer.*;
027
028/**
029 * Convenience static methods for serializing objects with all supported Juneau marshalling formats.
030 *
031 * <p>
032 * Designed for use with static imports to allow concise serialization code without explicitly
033 * referencing marshaller classes.
034 *
035 * <h5 class='figure'>Examples:</h5>
036 * <p class='bjava'>
037 *    <jk>import static</jk> org.apache.juneau.marshall.marshaller.MarshallUtils.*;
038 *
039 *    <jc>// Serialize — char-based formats return String.</jc>
040 *    String <jv>a</jv> = json(<jv>myBean</jv>);
041 *    String <jv>b</jv> = json5(<jv>myBean</jv>);
042 *    String <jv>c</jv> = xml(<jv>myBean</jv>);
043 *    String <jv>d</jv> = html(<jv>myBean</jv>);
044 *    String <jv>e</jv> = yaml(<jv>myBean</jv>);
045 *
046 *    <jc>// Serialize — write to a stream.</jc>
047 *    json(<jv>myBean</jv>, myWriter);
048 *
049 *    <jc>// Serialize — binary formats return byte[].</jc>
050 *    <jk>byte</jk>[] <jv>f</jv> = msgPack(<jv>myBean</jv>);
051 *    <jk>byte</jk>[] <jv>g</jv> = cbor(<jv>myBean</jv>);
052 *
053 *    <jc>// Parse — same method names, overloaded by input type.</jc>
054 *    MyBean <jv>b1</jv> = json(<jv>jsonString</jv>, MyBean.<jk>class</jk>);
055 *    MyBean <jv>b2</jv> = xml(<jv>xmlString</jv>, MyBean.<jk>class</jk>);
056 *    MyBean <jv>b3</jv> = msgPack(<jv>bytes</jv>, MyBean.<jk>class</jk>);
057 *
058 *    <jc>// Parse — parameterized types.</jc>
059 *    List&lt;MyBean&gt; <jv>list</jv> = json(<jv>jsonString</jv>, List.<jk>class</jk>, MyBean.<jk>class</jk>);
060 * </p>
061 *
062 * <h5 class='section'>See Also:</h5><ul>
063 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Marshallers">Marshallers</a>
064 * </ul>
065 */
066@SuppressWarnings({
067   "java:S6539", // Monster class; MarshallUtils is intentionally a single cohesive terse-marshalling-facade hub, one method family per format
068   "unchecked" // Parquet always returns List<T>; generic cast is safe by contract.
069})
070public final class MarshallUtils {
071
072   private MarshallUtils() {}
073
074   //-----------------------------------------------------------------------------------------------------------------
075   // Char-based formats (return String)
076   //-----------------------------------------------------------------------------------------------------------------
077
078   /**
079    * Serializes a Java object to a JSON string.
080    *
081    * <p>
082    * A shortcut for calling <c>Json.<jsm>of</jsm>(<jv>object</jv>)</c>.
083    *
084    * @param object The object to serialize.
085    * @return The serialized object.
086    * @throws SerializeException If a problem occurred trying to convert the output.
087    */
088   public static String json(Object object) throws SerializeException {
089      return Json.of(object);
090   }
091
092   /**
093    * Serializes a Java object to the specified JSON output.
094    *
095    * @param object The object to serialize.
096    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
097    * @return The output object.
098    * @throws SerializeException If a problem occurred trying to convert the output.
099    * @throws IOException Thrown by underlying stream.
100    */
101   public static Object json(Object object, Object output) throws SerializeException, IOException {
102      Json.DEFAULT.write(object, output); return output;
103   }
104
105   /**
106    * Parses a JSON input to the specified Java type.
107    *
108    * @param <T> The class type of the object being created.
109    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
110    * @param type The object type to create.
111    * @return The parsed object.
112    * @throws ParseException Malformed input encountered.
113    * @throws IOException Thrown by underlying stream.
114    */
115   public static <T> T json(Object input, Class<T> type) throws ParseException, IOException {
116      return Json.DEFAULT.read(input, type);
117   }
118
119   /**
120    * Parses a JSON input to the specified parameterized Java type.
121    *
122    * @param <T> The class type of the object being created.
123    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
124    * @param type The object type to create.
125    * @param args The type arguments of the class if it's a collection or map.
126    * @return The parsed object.
127    * @throws ParseException Malformed input encountered.
128    * @throws IOException Thrown by underlying stream.
129    */
130   public static <T> T json(Object input, Type type, Type... args) throws ParseException, IOException {
131      return Json.DEFAULT.read(input, type, args);
132   }
133
134   /**
135    * Parses a JSON string to the specified Java type.
136    *
137    * @param <T> The class type of the object being created.
138    * @param o The JSON input string.
139    * @param c The object type to create.
140    * @return The parsed object.
141    */
142   public static <T> T json(String o, Class<T> c) {
143      return safe(() -> Json.to(o, c));
144   }
145
146   /**
147    * Parses a JSON string to the specified parameterized Java type.
148    *
149    * @param <T> The class type of the object being created.
150    * @param input The JSON input string.
151    * @param type The object type to create.
152    * @param args The type arguments of the class if it's a collection or map.
153    * @return The parsed object.
154    * @throws ParseException Malformed input encountered.
155    */
156   public static <T> T json(String input, Type type, Type... args) throws ParseException {
157      return Json.to(input, type, args);
158   }
159
160   /**
161    * Serializes a Java object to a JSON5 string.
162    *
163    * <p>
164    * A shortcut for calling <c>Json5.<jsm>of</jsm>(<jv>object</jv>)</c>.
165    *
166    * @param object The object to serialize.
167    * @return The serialized object.
168    * @throws SerializeException If a problem occurred trying to convert the output.
169    */
170   public static String json5(Object object) throws SerializeException {
171      return Json5.of(object);
172   }
173
174   /**
175    * Serializes a Java object to the specified JSON5 output.
176    *
177    * @param object The object to serialize.
178    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
179    * @return The output object.
180    * @throws SerializeException If a problem occurred trying to convert the output.
181    * @throws IOException Thrown by underlying stream.
182    */
183   public static Object json5(Object object, Object output) throws SerializeException, IOException {
184      Json5.DEFAULT.write(object, output); return output;
185   }
186
187   /**
188    * Parses a JSON5 input to the specified Java type.
189    *
190    * @param <T> The class type of the object being created.
191    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
192    * @param type The object type to create.
193    * @return The parsed object.
194    * @throws ParseException Malformed input encountered.
195    * @throws IOException Thrown by underlying stream.
196    */
197   public static <T> T json5(Object input, Class<T> type) throws ParseException, IOException {
198      return Json5.DEFAULT.read(input, type);
199   }
200
201   /**
202    * Parses a JSON5 input to the specified parameterized Java type.
203    *
204    * @param <T> The class type of the object being created.
205    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
206    * @param type The object type to create.
207    * @param args The type arguments of the class if it's a collection or map.
208    * @return The parsed object.
209    * @throws ParseException Malformed input encountered.
210    * @throws IOException Thrown by underlying stream.
211    */
212   public static <T> T json5(Object input, Type type, Type... args) throws ParseException, IOException {
213      return Json5.DEFAULT.read(input, type, args);
214   }
215
216   /**
217    * Parses a JSON5 string to the specified Java type.
218    *
219    * @param <T> The class type of the object being created.
220    * @param o The JSON5 input string.
221    * @param c The object type to create.
222    * @return The parsed object.
223    */
224   public static <T> T json5(String o, Class<T> c) {
225      return safe(() -> Json5.to(o, c));
226   }
227
228   /**
229    * Parses a JSON5 string to the specified parameterized Java type.
230    *
231    * @param <T> The class type of the object being created.
232    * @param input The JSON5 input string.
233    * @param type The object type to create.
234    * @param args The type arguments of the class if it's a collection or map.
235    * @return The parsed object.
236    * @throws ParseException Malformed input encountered.
237    */
238   public static <T> T json5(String input, Type type, Type... args) throws ParseException {
239      return Json5.to(input, type, args);
240   }
241
242   /**
243    * Serializes a Java object to a JSON Lines string.
244    *
245    * <p>
246    * A shortcut for calling <c>Jsonl.<jsm>of</jsm>(<jv>object</jv>)</c>.
247    *
248    * @param object The object to serialize.
249    * @return The serialized object.
250    * @throws SerializeException If a problem occurred trying to convert the output.
251    */
252   public static String jsonl(Object object) throws SerializeException {
253      return Jsonl.of(object);
254   }
255
256   /**
257    * Serializes a Java object to the specified JSON Lines output.
258    *
259    * @param object The object to serialize.
260    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
261    * @return The output object.
262    * @throws SerializeException If a problem occurred trying to convert the output.
263    * @throws IOException Thrown by underlying stream.
264    */
265   public static Object jsonl(Object object, Object output) throws SerializeException, IOException {
266      Jsonl.DEFAULT.write(object, output); return output;
267   }
268
269   /**
270    * Parses a JSON Lines input to the specified Java type.
271    *
272    * @param <T> The class type of the object being created.
273    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
274    * @param type The object type to create.
275    * @return The parsed object.
276    * @throws ParseException Malformed input encountered.
277    * @throws IOException Thrown by underlying stream.
278    */
279   public static <T> T jsonl(Object input, Class<T> type) throws ParseException, IOException {
280      return Jsonl.DEFAULT.read(input, type);
281   }
282
283   /**
284    * Parses a JSON Lines input to the specified parameterized Java type.
285    *
286    * @param <T> The class type of the object being created.
287    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
288    * @param type The object type to create.
289    * @param args The type arguments of the class if it's a collection or map.
290    * @return The parsed object.
291    * @throws ParseException Malformed input encountered.
292    * @throws IOException Thrown by underlying stream.
293    */
294   public static <T> T jsonl(Object input, Type type, Type... args) throws ParseException, IOException {
295      return Jsonl.DEFAULT.read(input, type, args);
296   }
297
298   /**
299    * Parses a JSON Lines string to the specified Java type.
300    *
301    * @param <T> The class type of the object being created.
302    * @param o The JSON Lines input string.
303    * @param c The object type to create.
304    * @return The parsed object.
305    */
306   public static <T> T jsonl(String o, Class<T> c) {
307      return safe(() -> Jsonl.to(o, c));
308   }
309
310   /**
311    * Parses a JSON Lines string to the specified parameterized Java type.
312    *
313    * @param <T> The class type of the object being created.
314    * @param input The JSON Lines input string.
315    * @param type The object type to create.
316    * @param args The type arguments of the class if it's a collection or map.
317    * @return The parsed object.
318    * @throws ParseException Malformed input encountered.
319    */
320   public static <T> T jsonl(String input, Type type, Type... args) throws ParseException {
321      return Jsonl.to(input, type, args);
322   }
323
324   /**
325    * Serializes a Java object to a canonical JSON string (RFC 8785).
326    *
327    * <p>
328    * A shortcut for calling <c>Jcs.<jsm>of</jsm>(<jv>object</jv>)</c>.
329    *
330    * @param object The object to serialize.
331    * @return The serialized object.
332    * @throws SerializeException If a problem occurred trying to convert the output.
333    */
334   public static String jcs(Object object) throws SerializeException {
335      return Jcs.of(object);
336   }
337
338   /**
339    * Serializes a Java object to the specified canonical JSON output.
340    *
341    * @param object The object to serialize.
342    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
343    * @return The output object.
344    * @throws SerializeException If a problem occurred trying to convert the output.
345    * @throws IOException Thrown by underlying stream.
346    */
347   public static Object jcs(Object object, Object output) throws SerializeException, IOException {
348      Jcs.DEFAULT.write(object, output); return output;
349   }
350
351   /**
352    * Parses a canonical JSON input to the specified Java type.
353    *
354    * @param <T> The class type of the object being created.
355    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
356    * @param type The object type to create.
357    * @return The parsed object.
358    * @throws ParseException Malformed input encountered.
359    * @throws IOException Thrown by underlying stream.
360    */
361   public static <T> T jcs(Object input, Class<T> type) throws ParseException, IOException {
362      return Jcs.DEFAULT.read(input, type);
363   }
364
365   /**
366    * Parses a canonical JSON input to the specified parameterized Java type.
367    *
368    * @param <T> The class type of the object being created.
369    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
370    * @param type The object type to create.
371    * @param args The type arguments of the class if it's a collection or map.
372    * @return The parsed object.
373    * @throws ParseException Malformed input encountered.
374    * @throws IOException Thrown by underlying stream.
375    */
376   public static <T> T jcs(Object input, Type type, Type... args) throws ParseException, IOException {
377      return Jcs.DEFAULT.read(input, type, args);
378   }
379
380   /**
381    * Parses a canonical JSON string (RFC 8785) to the specified Java type.
382    *
383    * @param <T> The class type of the object being created.
384    * @param o The JCS input string.
385    * @param c The object type to create.
386    * @return The parsed object.
387    */
388   public static <T> T jcs(String o, Class<T> c) {
389      return safe(() -> Jcs.to(o, c));
390   }
391
392   /**
393    * Parses a canonical JSON string (RFC 8785) to the specified parameterized Java type.
394    *
395    * @param <T> The class type of the object being created.
396    * @param input The JCS input string.
397    * @param type The object type to create.
398    * @param args The type arguments of the class if it's a collection or map.
399    * @return The parsed object.
400    * @throws ParseException Malformed input encountered.
401    */
402   public static <T> T jcs(String input, Type type, Type... args) throws ParseException {
403      return Jcs.to(input, type, args);
404   }
405
406   /**
407    * Serializes a Java object to an HJSON string.
408    *
409    * <p>
410    * A shortcut for calling <c>Hjson.<jsm>of</jsm>(<jv>object</jv>)</c>.
411    *
412    * @param object The object to serialize.
413    * @return The serialized object.
414    * @throws SerializeException If a problem occurred trying to convert the output.
415    */
416   public static String hjson(Object object) throws SerializeException {
417      return Hjson.of(object);
418   }
419
420   /**
421    * Serializes a Java object to the specified HJSON output.
422    *
423    * @param object The object to serialize.
424    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
425    * @return The output object.
426    * @throws SerializeException If a problem occurred trying to convert the output.
427    * @throws IOException Thrown by underlying stream.
428    */
429   public static Object hjson(Object object, Object output) throws SerializeException, IOException {
430      Hjson.DEFAULT.write(object, output); return output;
431   }
432
433   /**
434    * Parses an HJSON input to the specified Java type.
435    *
436    * @param <T> The class type of the object being created.
437    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
438    * @param type The object type to create.
439    * @return The parsed object.
440    * @throws ParseException Malformed input encountered.
441    * @throws IOException Thrown by underlying stream.
442    */
443   public static <T> T hjson(Object input, Class<T> type) throws ParseException, IOException {
444      return Hjson.DEFAULT.read(input, type);
445   }
446
447   /**
448    * Parses an HJSON input to the specified parameterized Java type.
449    *
450    * @param <T> The class type of the object being created.
451    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
452    * @param type The object type to create.
453    * @param args The type arguments of the class if it's a collection or map.
454    * @return The parsed object.
455    * @throws ParseException Malformed input encountered.
456    * @throws IOException Thrown by underlying stream.
457    */
458   public static <T> T hjson(Object input, Type type, Type... args) throws ParseException, IOException {
459      return Hjson.DEFAULT.read(input, type, args);
460   }
461
462   /**
463    * Parses an HJSON string to the specified Java type.
464    *
465    * @param <T> The class type of the object being created.
466    * @param o The HJSON input string.
467    * @param c The object type to create.
468    * @return The parsed object.
469    */
470   public static <T> T hjson(String o, Class<T> c) {
471      return safe(() -> Hjson.to(o, c));
472   }
473
474   /**
475    * Parses an HJSON string to the specified parameterized Java type.
476    *
477    * @param <T> The class type of the object being created.
478    * @param input The HJSON input string.
479    * @param type The object type to create.
480    * @param args The type arguments of the class if it's a collection or map.
481    * @return The parsed object.
482    * @throws ParseException Malformed input encountered.
483    */
484   public static <T> T hjson(String input, Type type, Type... args) throws ParseException {
485      return Hjson.to(input, type, args);
486   }
487
488   /**
489    * Serializes a Java object to an XML string.
490    *
491    * <p>
492    * A shortcut for calling <c>Xml.<jsm>of</jsm>(<jv>object</jv>)</c>.
493    *
494    * @param object The object to serialize.
495    * @return The serialized object.
496    * @throws SerializeException If a problem occurred trying to convert the output.
497    */
498   public static String xml(Object object) throws SerializeException {
499      return Xml.of(object);
500   }
501
502   /**
503    * Serializes a Java object to the specified XML output.
504    *
505    * @param object The object to serialize.
506    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
507    * @return The output object.
508    * @throws SerializeException If a problem occurred trying to convert the output.
509    * @throws IOException Thrown by underlying stream.
510    */
511   public static Object xml(Object object, Object output) throws SerializeException, IOException {
512      Xml.DEFAULT.write(object, output); return output;
513   }
514
515   /**
516    * Parses an XML input to the specified Java type.
517    *
518    * @param <T> The class type of the object being created.
519    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
520    * @param type The object type to create.
521    * @return The parsed object.
522    * @throws ParseException Malformed input encountered.
523    * @throws IOException Thrown by underlying stream.
524    */
525   public static <T> T xml(Object input, Class<T> type) throws ParseException, IOException {
526      return Xml.DEFAULT.read(input, type);
527   }
528
529   /**
530    * Parses an XML input to the specified parameterized Java type.
531    *
532    * @param <T> The class type of the object being created.
533    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
534    * @param type The object type to create.
535    * @param args The type arguments of the class if it's a collection or map.
536    * @return The parsed object.
537    * @throws ParseException Malformed input encountered.
538    * @throws IOException Thrown by underlying stream.
539    */
540   public static <T> T xml(Object input, Type type, Type... args) throws ParseException, IOException {
541      return Xml.DEFAULT.read(input, type, args);
542   }
543
544   /**
545    * Parses an XML string to the specified Java type.
546    *
547    * @param <T> The class type of the object being created.
548    * @param o The XML input string.
549    * @param c The object type to create.
550    * @return The parsed object.
551    */
552   public static <T> T xml(String o, Class<T> c) {
553      return safe(() -> Xml.to(o, c));
554   }
555
556   /**
557    * Parses an XML string to the specified parameterized Java type.
558    *
559    * @param <T> The class type of the object being created.
560    * @param input The XML input string.
561    * @param type The object type to create.
562    * @param args The type arguments of the class if it's a collection or map.
563    * @return The parsed object.
564    * @throws ParseException Malformed input encountered.
565    */
566   public static <T> T xml(String input, Type type, Type... args) throws ParseException {
567      return Xml.to(input, type, args);
568   }
569
570   /**
571    * Serializes a Java object to an HTML string.
572    *
573    * <p>
574    * A shortcut for calling <c>Html.<jsm>of</jsm>(<jv>object</jv>)</c>.
575    *
576    * @param object The object to serialize.
577    * @return The serialized object.
578    * @throws SerializeException If a problem occurred trying to convert the output.
579    */
580   public static String html(Object object) throws SerializeException {
581      return Html.of(object);
582   }
583
584   /**
585    * Serializes a Java object to the specified HTML output.
586    *
587    * @param object The object to serialize.
588    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
589    * @return The output object.
590    * @throws SerializeException If a problem occurred trying to convert the output.
591    * @throws IOException Thrown by underlying stream.
592    */
593   public static Object html(Object object, Object output) throws SerializeException, IOException {
594      Html.DEFAULT.write(object, output); return output;
595   }
596
597   /**
598    * Parses an HTML input to the specified Java type.
599    *
600    * @param <T> The class type of the object being created.
601    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
602    * @param type The object type to create.
603    * @return The parsed object.
604    * @throws ParseException Malformed input encountered.
605    * @throws IOException Thrown by underlying stream.
606    */
607   public static <T> T html(Object input, Class<T> type) throws ParseException, IOException {
608      return Html.DEFAULT.read(input, type);
609   }
610
611   /**
612    * Parses an HTML input to the specified parameterized Java type.
613    *
614    * @param <T> The class type of the object being created.
615    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
616    * @param type The object type to create.
617    * @param args The type arguments of the class if it's a collection or map.
618    * @return The parsed object.
619    * @throws ParseException Malformed input encountered.
620    * @throws IOException Thrown by underlying stream.
621    */
622   public static <T> T html(Object input, Type type, Type... args) throws ParseException, IOException {
623      return Html.DEFAULT.read(input, type, args);
624   }
625
626   /**
627    * Parses an HTML string to the specified Java type.
628    *
629    * @param <T> The class type of the object being created.
630    * @param o The HTML input string.
631    * @param c The object type to create.
632    * @return The parsed object.
633    */
634   public static <T> T html(String o, Class<T> c) {
635      return safe(() -> Html.to(o, c));
636   }
637
638   /**
639    * Parses an HTML string to the specified parameterized Java type.
640    *
641    * @param <T> The class type of the object being created.
642    * @param input The HTML input string.
643    * @param type The object type to create.
644    * @param args The type arguments of the class if it's a collection or map.
645    * @return The parsed object.
646    * @throws ParseException Malformed input encountered.
647    */
648   public static <T> T html(String input, Type type, Type... args) throws ParseException {
649      return Html.to(input, type, args);
650   }
651
652   /**
653    * Serializes a Java object to a UON string.
654    *
655    * <p>
656    * A shortcut for calling <c>Uon.<jsm>of</jsm>(<jv>object</jv>)</c>.
657    *
658    * @param object The object to serialize.
659    * @return The serialized object.
660    * @throws SerializeException If a problem occurred trying to convert the output.
661    */
662   public static String uon(Object object) throws SerializeException {
663      return Uon.of(object);
664   }
665
666   /**
667    * Serializes a Java object to the specified UON output.
668    *
669    * @param object The object to serialize.
670    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
671    * @return The output object.
672    * @throws SerializeException If a problem occurred trying to convert the output.
673    * @throws IOException Thrown by underlying stream.
674    */
675   public static Object uon(Object object, Object output) throws SerializeException, IOException {
676      Uon.DEFAULT.write(object, output); return output;
677   }
678
679   /**
680    * Parses a UON input to the specified Java type.
681    *
682    * @param <T> The class type of the object being created.
683    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
684    * @param type The object type to create.
685    * @return The parsed object.
686    * @throws ParseException Malformed input encountered.
687    * @throws IOException Thrown by underlying stream.
688    */
689   public static <T> T uon(Object input, Class<T> type) throws ParseException, IOException {
690      return Uon.DEFAULT.read(input, type);
691   }
692
693   /**
694    * Parses a UON input to the specified parameterized Java type.
695    *
696    * @param <T> The class type of the object being created.
697    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
698    * @param type The object type to create.
699    * @param args The type arguments of the class if it's a collection or map.
700    * @return The parsed object.
701    * @throws ParseException Malformed input encountered.
702    * @throws IOException Thrown by underlying stream.
703    */
704   public static <T> T uon(Object input, Type type, Type... args) throws ParseException, IOException {
705      return Uon.DEFAULT.read(input, type, args);
706   }
707
708   /**
709    * Parses a UON string to the specified Java type.
710    *
711    * @param <T> The class type of the object being created.
712    * @param o The UON input string.
713    * @param c The object type to create.
714    * @return The parsed object.
715    */
716   public static <T> T uon(String o, Class<T> c) {
717      return safe(() -> Uon.to(o, c));
718   }
719
720   /**
721    * Parses a UON string to the specified parameterized Java type.
722    *
723    * @param <T> The class type of the object being created.
724    * @param input The UON input string.
725    * @param type The object type to create.
726    * @param args The type arguments of the class if it's a collection or map.
727    * @return The parsed object.
728    * @throws ParseException Malformed input encountered.
729    */
730   public static <T> T uon(String input, Type type, Type... args) throws ParseException {
731      return Uon.to(input, type, args);
732   }
733
734   /**
735    * Serializes a Java object to a URL-encoding string.
736    *
737    * <p>
738    * A shortcut for calling <c>UrlEncoding.<jsm>of</jsm>(<jv>object</jv>)</c>.
739    *
740    * @param object The object to serialize.
741    * @return The serialized object.
742    * @throws SerializeException If a problem occurred trying to convert the output.
743    */
744   public static String urlEncoding(Object object) throws SerializeException {
745      return UrlEncoding.of(object);
746   }
747
748   /**
749    * Serializes a Java object to the specified URL-encoding output.
750    *
751    * @param object The object to serialize.
752    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
753    * @return The output object.
754    * @throws SerializeException If a problem occurred trying to convert the output.
755    * @throws IOException Thrown by underlying stream.
756    */
757   public static Object urlEncoding(Object object, Object output) throws SerializeException, IOException {
758      UrlEncoding.DEFAULT.write(object, output); return output;
759   }
760
761   /**
762    * Parses a URL-encoding input to the specified Java type.
763    *
764    * @param <T> The class type of the object being created.
765    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
766    * @param type The object type to create.
767    * @return The parsed object.
768    * @throws ParseException Malformed input encountered.
769    * @throws IOException Thrown by underlying stream.
770    */
771   public static <T> T urlEncoding(Object input, Class<T> type) throws ParseException, IOException {
772      return UrlEncoding.DEFAULT.read(input, type);
773   }
774
775   /**
776    * Parses a URL-encoding input to the specified parameterized Java type.
777    *
778    * @param <T> The class type of the object being created.
779    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
780    * @param type The object type to create.
781    * @param args The type arguments of the class if it's a collection or map.
782    * @return The parsed object.
783    * @throws ParseException Malformed input encountered.
784    * @throws IOException Thrown by underlying stream.
785    */
786   public static <T> T urlEncoding(Object input, Type type, Type... args) throws ParseException, IOException {
787      return UrlEncoding.DEFAULT.read(input, type, args);
788   }
789
790   /**
791    * Parses a URL-encoding string to the specified Java type.
792    *
793    * @param <T> The class type of the object being created.
794    * @param o The URL-encoding input string.
795    * @param c The object type to create.
796    * @return The parsed object.
797    */
798   public static <T> T urlEncoding(String o, Class<T> c) {
799      return safe(() -> UrlEncoding.to(o, c));
800   }
801
802   /**
803    * Parses a URL-encoding string to the specified parameterized Java type.
804    *
805    * @param <T> The class type of the object being created.
806    * @param input The URL-encoding input string.
807    * @param type The object type to create.
808    * @param args The type arguments of the class if it's a collection or map.
809    * @return The parsed object.
810    * @throws ParseException Malformed input encountered.
811    */
812   public static <T> T urlEncoding(String input, Type type, Type... args) throws ParseException {
813      return UrlEncoding.to(input, type, args);
814   }
815
816   /**
817    * Serializes a Java object to a YAML string.
818    *
819    * <p>
820    * A shortcut for calling <c>Yaml.<jsm>of</jsm>(<jv>object</jv>)</c>.
821    *
822    * @param object The object to serialize.
823    * @return The serialized object.
824    * @throws SerializeException If a problem occurred trying to convert the output.
825    */
826   public static String yaml(Object object) throws SerializeException {
827      return Yaml.of(object);
828   }
829
830   /**
831    * Serializes a Java object to the specified YAML output.
832    *
833    * @param object The object to serialize.
834    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
835    * @return The output object.
836    * @throws SerializeException If a problem occurred trying to convert the output.
837    * @throws IOException Thrown by underlying stream.
838    */
839   public static Object yaml(Object object, Object output) throws SerializeException, IOException {
840      Yaml.DEFAULT.write(object, output); return output;
841   }
842
843   /**
844    * Parses a YAML input to the specified Java type.
845    *
846    * @param <T> The class type of the object being created.
847    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
848    * @param type The object type to create.
849    * @return The parsed object.
850    * @throws ParseException Malformed input encountered.
851    * @throws IOException Thrown by underlying stream.
852    */
853   public static <T> T yaml(Object input, Class<T> type) throws ParseException, IOException {
854      return Yaml.DEFAULT.read(input, type);
855   }
856
857   /**
858    * Parses a YAML input to the specified parameterized Java type.
859    *
860    * @param <T> The class type of the object being created.
861    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
862    * @param type The object type to create.
863    * @param args The type arguments of the class if it's a collection or map.
864    * @return The parsed object.
865    * @throws ParseException Malformed input encountered.
866    * @throws IOException Thrown by underlying stream.
867    */
868   public static <T> T yaml(Object input, Type type, Type... args) throws ParseException, IOException {
869      return Yaml.DEFAULT.read(input, type, args);
870   }
871
872   /**
873    * Parses a YAML string to the specified Java type.
874    *
875    * @param <T> The class type of the object being created.
876    * @param o The YAML input string.
877    * @param c The object type to create.
878    * @return The parsed object.
879    */
880   public static <T> T yaml(String o, Class<T> c) {
881      return safe(() -> Yaml.to(o, c));
882   }
883
884   /**
885    * Parses a YAML string to the specified parameterized Java type.
886    *
887    * @param <T> The class type of the object being created.
888    * @param input The YAML input string.
889    * @param type The object type to create.
890    * @param args The type arguments of the class if it's a collection or map.
891    * @return The parsed object.
892    * @throws ParseException Malformed input encountered.
893    */
894   public static <T> T yaml(String input, Type type, Type... args) throws ParseException {
895      return Yaml.to(input, type, args);
896   }
897
898   /**
899    * Serializes a Java object to a CSV string.
900    *
901    * <p>
902    * A shortcut for calling <c>Csv.<jsm>of</jsm>(<jv>object</jv>)</c>.
903    *
904    * @param object The object to serialize.
905    * @return The serialized object.
906    * @throws SerializeException If a problem occurred trying to convert the output.
907    */
908   public static String csv(Object object) throws SerializeException {
909      return Csv.of(object);
910   }
911
912   /**
913    * Serializes a Java object to the specified CSV output.
914    *
915    * @param object The object to serialize.
916    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
917    * @return The output object.
918    * @throws SerializeException If a problem occurred trying to convert the output.
919    * @throws IOException Thrown by underlying stream.
920    */
921   public static Object csv(Object object, Object output) throws SerializeException, IOException {
922      Csv.DEFAULT.write(object, output); return output;
923   }
924
925   /**
926    * Parses a CSV input to the specified Java type.
927    *
928    * @param <T> The class type of the object being created.
929    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
930    * @param type The object type to create.
931    * @return The parsed object.
932    * @throws ParseException Malformed input encountered.
933    * @throws IOException Thrown by underlying stream.
934    */
935   public static <T> T csv(Object input, Class<T> type) throws ParseException, IOException {
936      return Csv.DEFAULT.read(input, type);
937   }
938
939   /**
940    * Parses a CSV input to the specified parameterized Java type.
941    *
942    * @param <T> The class type of the object being created.
943    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
944    * @param type The object type to create.
945    * @param args The type arguments of the class if it's a collection or map.
946    * @return The parsed object.
947    * @throws ParseException Malformed input encountered.
948    * @throws IOException Thrown by underlying stream.
949    */
950   public static <T> T csv(Object input, Type type, Type... args) throws ParseException, IOException {
951      return Csv.DEFAULT.read(input, type, args);
952   }
953
954   /**
955    * Parses a CSV string to the specified Java type.
956    *
957    * @param <T> The class type of the object being created.
958    * @param o The CSV input string.
959    * @param c The object type to create.
960    * @return The parsed object.
961    */
962   public static <T> T csv(String o, Class<T> c) {
963      return safe(() -> Csv.to(o, c));
964   }
965
966   /**
967    * Parses a CSV string to the specified parameterized Java type.
968    *
969    * @param <T> The class type of the object being created.
970    * @param input The CSV input string.
971    * @param type The object type to create.
972    * @param args The type arguments of the class if it's a collection or map.
973    * @return The parsed object.
974    * @throws ParseException Malformed input encountered.
975    */
976   public static <T> T csv(String input, Type type, Type... args) throws ParseException {
977      return Csv.to(input, type, args);
978   }
979
980   /**
981    * Serializes a Java object to an OpenAPI string.
982    *
983    * <p>
984    * A shortcut for calling <c>OpenApi.<jsm>of</jsm>(<jv>object</jv>)</c>.
985    *
986    * @param object The object to serialize.
987    * @return The serialized object.
988    * @throws SerializeException If a problem occurred trying to convert the output.
989    */
990   public static String openApi(Object object) throws SerializeException {
991      return OpenApi.of(object);
992   }
993
994   /**
995    * Serializes a Java object to the specified OpenAPI output.
996    *
997    * @param object The object to serialize.
998    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
999    * @return The output object.
1000    * @throws SerializeException If a problem occurred trying to convert the output.
1001    * @throws IOException Thrown by underlying stream.
1002    */
1003   public static Object openApi(Object object, Object output) throws SerializeException, IOException {
1004      OpenApi.DEFAULT.write(object, output); return output;
1005   }
1006
1007   /**
1008    * Parses an OpenAPI input to the specified Java type.
1009    *
1010    * @param <T> The class type of the object being created.
1011    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1012    * @param type The object type to create.
1013    * @return The parsed object.
1014    * @throws ParseException Malformed input encountered.
1015    * @throws IOException Thrown by underlying stream.
1016    */
1017   public static <T> T openApi(Object input, Class<T> type) throws ParseException, IOException {
1018      return OpenApi.DEFAULT.read(input, type);
1019   }
1020
1021   /**
1022    * Parses an OpenAPI input to the specified parameterized Java type.
1023    *
1024    * @param <T> The class type of the object being created.
1025    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1026    * @param type The object type to create.
1027    * @param args The type arguments of the class if it's a collection or map.
1028    * @return The parsed object.
1029    * @throws ParseException Malformed input encountered.
1030    * @throws IOException Thrown by underlying stream.
1031    */
1032   public static <T> T openApi(Object input, Type type, Type... args) throws ParseException, IOException {
1033      return OpenApi.DEFAULT.read(input, type, args);
1034   }
1035
1036   /**
1037    * Parses an OpenAPI string to the specified Java type.
1038    *
1039    * @param <T> The class type of the object being created.
1040    * @param o The OpenAPI input string.
1041    * @param c The object type to create.
1042    * @return The parsed object.
1043    */
1044   public static <T> T openApi(String o, Class<T> c) {
1045      return safe(() -> OpenApi.to(o, c));
1046   }
1047
1048   /**
1049    * Parses an OpenAPI string to the specified parameterized Java type.
1050    *
1051    * @param <T> The class type of the object being created.
1052    * @param input The OpenAPI input string.
1053    * @param type The object type to create.
1054    * @param args The type arguments of the class if it's a collection or map.
1055    * @return The parsed object.
1056    * @throws ParseException Malformed input encountered.
1057    */
1058   public static <T> T openApi(String input, Type type, Type... args) throws ParseException {
1059      return OpenApi.to(input, type, args);
1060   }
1061
1062   /**
1063    * Serializes a Java object to a plain-text string.
1064    *
1065    * <p>
1066    * A shortcut for calling <c>PlainText.<jsm>of</jsm>(<jv>object</jv>)</c>.
1067    *
1068    * @param object The object to serialize.
1069    * @return The serialized object.
1070    * @throws SerializeException If a problem occurred trying to convert the output.
1071    */
1072   public static String plainText(Object object) throws SerializeException {
1073      return PlainText.of(object);
1074   }
1075
1076   /**
1077    * Serializes a Java object to the specified plain-text output.
1078    *
1079    * @param object The object to serialize.
1080    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1081    * @return The output object.
1082    * @throws SerializeException If a problem occurred trying to convert the output.
1083    * @throws IOException Thrown by underlying stream.
1084    */
1085   public static Object plainText(Object object, Object output) throws SerializeException, IOException {
1086      PlainText.DEFAULT.write(object, output); return output;
1087   }
1088
1089   /**
1090    * Parses a plain-text input to the specified Java type.
1091    *
1092    * @param <T> The class type of the object being created.
1093    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1094    * @param type The object type to create.
1095    * @return The parsed object.
1096    * @throws ParseException Malformed input encountered.
1097    * @throws IOException Thrown by underlying stream.
1098    */
1099   public static <T> T plainText(Object input, Class<T> type) throws ParseException, IOException {
1100      return PlainText.DEFAULT.read(input, type);
1101   }
1102
1103   /**
1104    * Parses a plain-text input to the specified parameterized Java type.
1105    *
1106    * @param <T> The class type of the object being created.
1107    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1108    * @param type The object type to create.
1109    * @param args The type arguments of the class if it's a collection or map.
1110    * @return The parsed object.
1111    * @throws ParseException Malformed input encountered.
1112    * @throws IOException Thrown by underlying stream.
1113    */
1114   public static <T> T plainText(Object input, Type type, Type... args) throws ParseException, IOException {
1115      return PlainText.DEFAULT.read(input, type, args);
1116   }
1117
1118   /**
1119    * Parses a plain-text string to the specified Java type.
1120    *
1121    * @param <T> The class type of the object being created.
1122    * @param o The plain-text input string.
1123    * @param c The object type to create.
1124    * @return The parsed object.
1125    */
1126   public static <T> T plainText(String o, Class<T> c) {
1127      return safe(() -> PlainText.to(o, c));
1128   }
1129
1130   /**
1131    * Parses a plain-text string to the specified parameterized Java type.
1132    *
1133    * @param <T> The class type of the object being created.
1134    * @param input The plain-text input string.
1135    * @param type The object type to create.
1136    * @param args The type arguments of the class if it's a collection or map.
1137    * @return The parsed object.
1138    * @throws ParseException Malformed input encountered.
1139    */
1140   public static <T> T plainText(String input, Type type, Type... args) throws ParseException {
1141      return PlainText.to(input, type, args);
1142   }
1143
1144   /**
1145    * Serializes a Java object to an inline Markdown string.
1146    *
1147    * <p>
1148    * A shortcut for calling <c>Markdown.<jsm>of</jsm>(<jv>object</jv>)</c>.
1149    *
1150    * @param object The object to serialize.
1151    * @return The serialized object.
1152    * @throws SerializeException If a problem occurred trying to convert the output.
1153    */
1154   public static String markdown(Object object) throws SerializeException {
1155      return Markdown.of(object);
1156   }
1157
1158   /**
1159    * Serializes a Java object to the specified Markdown output.
1160    *
1161    * @param object The object to serialize.
1162    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1163    * @return The output object.
1164    * @throws SerializeException If a problem occurred trying to convert the output.
1165    * @throws IOException Thrown by underlying stream.
1166    */
1167   public static Object markdown(Object object, Object output) throws SerializeException, IOException {
1168      Markdown.DEFAULT.write(object, output); return output;
1169   }
1170
1171   /**
1172    * Parses a Markdown input to the specified Java type.
1173    *
1174    * @param <T> The class type of the object being created.
1175    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1176    * @param type The object type to create.
1177    * @return The parsed object.
1178    * @throws ParseException Malformed input encountered.
1179    * @throws IOException Thrown by underlying stream.
1180    */
1181   public static <T> T markdown(Object input, Class<T> type) throws ParseException, IOException {
1182      return Markdown.DEFAULT.read(input, type);
1183   }
1184
1185   /**
1186    * Parses a Markdown input to the specified parameterized Java type.
1187    *
1188    * @param <T> The class type of the object being created.
1189    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1190    * @param type The object type to create.
1191    * @param args The type arguments of the class if it's a collection or map.
1192    * @return The parsed object.
1193    * @throws ParseException Malformed input encountered.
1194    * @throws IOException Thrown by underlying stream.
1195    */
1196   public static <T> T markdown(Object input, Type type, Type... args) throws ParseException, IOException {
1197      return Markdown.DEFAULT.read(input, type, args);
1198   }
1199
1200   /**
1201    * Parses an inline Markdown string to the specified Java type.
1202    *
1203    * @param <T> The class type of the object being created.
1204    * @param o The Markdown input string.
1205    * @param c The object type to create.
1206    * @return The parsed object.
1207    */
1208   public static <T> T markdown(String o, Class<T> c) {
1209      return safe(() -> Markdown.to(o, c));
1210   }
1211
1212   /**
1213    * Parses an inline Markdown string to the specified parameterized Java type.
1214    *
1215    * @param <T> The class type of the object being created.
1216    * @param input The Markdown input string.
1217    * @param type The object type to create.
1218    * @param args The type arguments of the class if it's a collection or map.
1219    * @return The parsed object.
1220    * @throws ParseException Malformed input encountered.
1221    */
1222   public static <T> T markdown(String input, Type type, Type... args) throws ParseException {
1223      return Markdown.to(input, type, args);
1224   }
1225
1226   /**
1227    * Serializes a Java object to a document-mode Markdown string (headings + tables).
1228    *
1229    * <p>
1230    * A shortcut for calling <c>MarkdownDoc.<jsm>of</jsm>(<jv>object</jv>)</c>.
1231    *
1232    * @param object The object to serialize.
1233    * @return The serialized object.
1234    * @throws SerializeException If a problem occurred trying to convert the output.
1235    */
1236   public static String markdownDoc(Object object) throws SerializeException {
1237      return MarkdownDoc.of(object);
1238   }
1239
1240   /**
1241    * Serializes a Java object to the specified document-mode Markdown output.
1242    *
1243    * @param object The object to serialize.
1244    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1245    * @return The output object.
1246    * @throws SerializeException If a problem occurred trying to convert the output.
1247    * @throws IOException Thrown by underlying stream.
1248    */
1249   public static Object markdownDoc(Object object, Object output) throws SerializeException, IOException {
1250      MarkdownDoc.DEFAULT.write(object, output); return output;
1251   }
1252
1253   /**
1254    * Parses a document-mode Markdown input to the specified Java type.
1255    *
1256    * @param <T> The class type of the object being created.
1257    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1258    * @param type The object type to create.
1259    * @return The parsed object.
1260    * @throws ParseException Malformed input encountered.
1261    * @throws IOException Thrown by underlying stream.
1262    */
1263   public static <T> T markdownDoc(Object input, Class<T> type) throws ParseException, IOException {
1264      return MarkdownDoc.DEFAULT.read(input, type);
1265   }
1266
1267   /**
1268    * Parses a document-mode Markdown input to the specified parameterized Java type.
1269    *
1270    * @param <T> The class type of the object being created.
1271    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1272    * @param type The object type to create.
1273    * @param args The type arguments of the class if it's a collection or map.
1274    * @return The parsed object.
1275    * @throws ParseException Malformed input encountered.
1276    * @throws IOException Thrown by underlying stream.
1277    */
1278   public static <T> T markdownDoc(Object input, Type type, Type... args) throws ParseException, IOException {
1279      return MarkdownDoc.DEFAULT.read(input, type, args);
1280   }
1281
1282   /**
1283    * Parses a document-mode Markdown string to the specified Java type.
1284    *
1285    * @param <T> The class type of the object being created.
1286    * @param o The Markdown input string.
1287    * @param c The object type to create.
1288    * @return The parsed object.
1289    */
1290   public static <T> T markdownDoc(String o, Class<T> c) {
1291      return safe(() -> MarkdownDoc.to(o, c));
1292   }
1293
1294   /**
1295    * Parses a document-mode Markdown string to the specified parameterized Java type.
1296    *
1297    * @param <T> The class type of the object being created.
1298    * @param input The Markdown input string.
1299    * @param type The object type to create.
1300    * @param args The type arguments of the class if it's a collection or map.
1301    * @return The parsed object.
1302    * @throws ParseException Malformed input encountered.
1303    */
1304   public static <T> T markdownDoc(String input, Type type, Type... args) throws ParseException {
1305      return MarkdownDoc.to(input, type, args);
1306   }
1307
1308   /**
1309    * Serializes a Java object to an INI/properties string.
1310    *
1311    * <p>
1312    * A shortcut for calling <c>Ini.<jsm>of</jsm>(<jv>object</jv>)</c>.
1313    *
1314    * @param object The object to serialize.
1315    * @return The serialized object.
1316    * @throws SerializeException If a problem occurred trying to convert the output.
1317    */
1318   public static String ini(Object object) throws SerializeException {
1319      return Ini.of(object);
1320   }
1321
1322   /**
1323    * Serializes a Java object to the specified INI/properties output.
1324    *
1325    * @param object The object to serialize.
1326    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1327    * @return The output object.
1328    * @throws SerializeException If a problem occurred trying to convert the output.
1329    * @throws IOException Thrown by underlying stream.
1330    */
1331   public static Object ini(Object object, Object output) throws SerializeException, IOException {
1332      Ini.DEFAULT.write(object, output); return output;
1333   }
1334
1335   /**
1336    * Parses an INI/properties input to the specified Java type.
1337    *
1338    * @param <T> The class type of the object being created.
1339    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1340    * @param type The object type to create.
1341    * @return The parsed object.
1342    * @throws ParseException Malformed input encountered.
1343    * @throws IOException Thrown by underlying stream.
1344    */
1345   public static <T> T ini(Object input, Class<T> type) throws ParseException, IOException {
1346      return Ini.DEFAULT.read(input, type);
1347   }
1348
1349   /**
1350    * Parses an INI/properties input to the specified parameterized Java type.
1351    *
1352    * @param <T> The class type of the object being created.
1353    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1354    * @param type The object type to create.
1355    * @param args The type arguments of the class if it's a collection or map.
1356    * @return The parsed object.
1357    * @throws ParseException Malformed input encountered.
1358    * @throws IOException Thrown by underlying stream.
1359    */
1360   public static <T> T ini(Object input, Type type, Type... args) throws ParseException, IOException {
1361      return Ini.DEFAULT.read(input, type, args);
1362   }
1363
1364   /**
1365    * Parses an INI/properties string to the specified Java type.
1366    *
1367    * @param <T> The class type of the object being created.
1368    * @param o The INI input string.
1369    * @param c The object type to create.
1370    * @return The parsed object.
1371    */
1372   public static <T> T ini(String o, Class<T> c) {
1373      return safe(() -> Ini.to(o, c));
1374   }
1375
1376   /**
1377    * Parses an INI/properties string to the specified parameterized Java type.
1378    *
1379    * @param <T> The class type of the object being created.
1380    * @param input The INI input string.
1381    * @param type The object type to create.
1382    * @param args The type arguments of the class if it's a collection or map.
1383    * @return The parsed object.
1384    * @throws ParseException Malformed input encountered.
1385    */
1386   public static <T> T ini(String input, Type type, Type... args) throws ParseException {
1387      return Ini.to(input, type, args);
1388   }
1389
1390   /**
1391    * Serializes a Java object to a TOML string.
1392    *
1393    * <p>
1394    * A shortcut for calling <c>Toml.<jsm>of</jsm>(<jv>object</jv>)</c>.
1395    *
1396    * @param object The object to serialize.
1397    * @return The serialized object.
1398    * @throws SerializeException If a problem occurred trying to convert the output.
1399    */
1400   public static String toml(Object object) throws SerializeException {
1401      return Toml.of(object);
1402   }
1403
1404   /**
1405    * Serializes a Java object to the specified TOML output.
1406    *
1407    * @param object The object to serialize.
1408    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1409    * @return The output object.
1410    * @throws SerializeException If a problem occurred trying to convert the output.
1411    * @throws IOException Thrown by underlying stream.
1412    */
1413   public static Object toml(Object object, Object output) throws SerializeException, IOException {
1414      Toml.DEFAULT.write(object, output); return output;
1415   }
1416
1417   /**
1418    * Parses a TOML input to the specified Java type.
1419    *
1420    * @param <T> The class type of the object being created.
1421    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1422    * @param type The object type to create.
1423    * @return The parsed object.
1424    * @throws ParseException Malformed input encountered.
1425    * @throws IOException Thrown by underlying stream.
1426    */
1427   public static <T> T toml(Object input, Class<T> type) throws ParseException, IOException {
1428      return Toml.DEFAULT.read(input, type);
1429   }
1430
1431   /**
1432    * Parses a TOML input to the specified parameterized Java type.
1433    *
1434    * @param <T> The class type of the object being created.
1435    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1436    * @param type The object type to create.
1437    * @param args The type arguments of the class if it's a collection or map.
1438    * @return The parsed object.
1439    * @throws ParseException Malformed input encountered.
1440    * @throws IOException Thrown by underlying stream.
1441    */
1442   public static <T> T toml(Object input, Type type, Type... args) throws ParseException, IOException {
1443      return Toml.DEFAULT.read(input, type, args);
1444   }
1445
1446   /**
1447    * Parses a TOML string to the specified Java type.
1448    *
1449    * @param <T> The class type of the object being created.
1450    * @param o The TOML input string.
1451    * @param c The object type to create.
1452    * @return The parsed object.
1453    */
1454   public static <T> T toml(String o, Class<T> c) {
1455      return safe(() -> Toml.to(o, c));
1456   }
1457
1458   /**
1459    * Parses a TOML string to the specified parameterized Java type.
1460    *
1461    * @param <T> The class type of the object being created.
1462    * @param input The TOML input string.
1463    * @param type The object type to create.
1464    * @param args The type arguments of the class if it's a collection or map.
1465    * @return The parsed object.
1466    * @throws ParseException Malformed input encountered.
1467    */
1468   public static <T> T toml(String input, Type type, Type... args) throws ParseException {
1469      return Toml.to(input, type, args);
1470   }
1471
1472   /**
1473    * Serializes a Java object to a HOCON string.
1474    *
1475    * <p>
1476    * A shortcut for calling <c>Hocon.<jsm>of</jsm>(<jv>object</jv>)</c>.
1477    *
1478    * @param object The object to serialize.
1479    * @return The serialized object.
1480    * @throws SerializeException If a problem occurred trying to convert the output.
1481    */
1482   public static String hocon(Object object) throws SerializeException {
1483      return Hocon.of(object);
1484   }
1485
1486   /**
1487    * Serializes a Java object to the specified HOCON output.
1488    *
1489    * @param object The object to serialize.
1490    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1491    * @return The output object.
1492    * @throws SerializeException If a problem occurred trying to convert the output.
1493    * @throws IOException Thrown by underlying stream.
1494    */
1495   public static Object hocon(Object object, Object output) throws SerializeException, IOException {
1496      Hocon.DEFAULT.write(object, output); return output;
1497   }
1498
1499   /**
1500    * Parses a HOCON input to the specified Java type.
1501    *
1502    * @param <T> The class type of the object being created.
1503    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1504    * @param type The object type to create.
1505    * @return The parsed object.
1506    * @throws ParseException Malformed input encountered.
1507    * @throws IOException Thrown by underlying stream.
1508    */
1509   public static <T> T hocon(Object input, Class<T> type) throws ParseException, IOException {
1510      return Hocon.DEFAULT.read(input, type);
1511   }
1512
1513   /**
1514    * Parses a HOCON input to the specified parameterized Java type.
1515    *
1516    * @param <T> The class type of the object being created.
1517    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1518    * @param type The object type to create.
1519    * @param args The type arguments of the class if it's a collection or map.
1520    * @return The parsed object.
1521    * @throws ParseException Malformed input encountered.
1522    * @throws IOException Thrown by underlying stream.
1523    */
1524   public static <T> T hocon(Object input, Type type, Type... args) throws ParseException, IOException {
1525      return Hocon.DEFAULT.read(input, type, args);
1526   }
1527
1528   /**
1529    * Parses a HOCON string to the specified Java type.
1530    *
1531    * @param <T> The class type of the object being created.
1532    * @param o The HOCON input string.
1533    * @param c The object type to create.
1534    * @return The parsed object.
1535    */
1536   public static <T> T hocon(String o, Class<T> c) {
1537      return safe(() -> Hocon.to(o, c));
1538   }
1539
1540   /**
1541    * Parses a HOCON string to the specified parameterized Java type.
1542    *
1543    * @param <T> The class type of the object being created.
1544    * @param input The HOCON input string.
1545    * @param type The object type to create.
1546    * @param args The type arguments of the class if it's a collection or map.
1547    * @return The parsed object.
1548    * @throws ParseException Malformed input encountered.
1549    */
1550   public static <T> T hocon(String input, Type type, Type... args) throws ParseException {
1551      return Hocon.to(input, type, args);
1552   }
1553
1554   /**
1555    * Serializes a Java object to a Protocol Buffers text string.
1556    *
1557    * <p>
1558    * A shortcut for calling <c>Prototext.<jsm>of</jsm>(<jv>object</jv>)</c>.
1559    *
1560    * @param object The object to serialize.
1561    * @return The serialized object.
1562    * @throws SerializeException If a problem occurred trying to convert the output.
1563    */
1564   public static String proto(Object object) throws SerializeException {
1565      return Prototext.of(object);
1566   }
1567
1568   /**
1569    * Serializes a Java object to the specified Protocol Buffers output.
1570    *
1571    * @param object The object to serialize.
1572    * @param output The output object (Writer, OutputStream, File, or StringBuilder).
1573    * @return The output object.
1574    * @throws SerializeException If a problem occurred trying to convert the output.
1575    * @throws IOException Thrown by underlying stream.
1576    */
1577   public static Object proto(Object object, Object output) throws SerializeException, IOException {
1578      Prototext.DEFAULT.write(object, output); return output;
1579   }
1580
1581   /**
1582    * Parses a Protocol Buffers input to the specified Java type.
1583    *
1584    * @param <T> The class type of the object being created.
1585    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1586    * @param type The object type to create.
1587    * @return The parsed object.
1588    * @throws ParseException Malformed input encountered.
1589    * @throws IOException Thrown by underlying stream.
1590    */
1591   public static <T> T proto(Object input, Class<T> type) throws ParseException, IOException {
1592      return Prototext.DEFAULT.read(input, type);
1593   }
1594
1595   /**
1596    * Parses a Protocol Buffers input to the specified parameterized Java type.
1597    *
1598    * @param <T> The class type of the object being created.
1599    * @param input The input (Reader, CharSequence, InputStream, byte[], or File).
1600    * @param type The object type to create.
1601    * @param args The type arguments of the class if it's a collection or map.
1602    * @return The parsed object.
1603    * @throws ParseException Malformed input encountered.
1604    * @throws IOException Thrown by underlying stream.
1605    */
1606   public static <T> T proto(Object input, Type type, Type... args) throws ParseException, IOException {
1607      return Prototext.DEFAULT.read(input, type, args);
1608   }
1609
1610   /**
1611    * Parses a Protocol Buffers text string to the specified Java type.
1612    *
1613    * @param <T> The class type of the object being created.
1614    * @param o The Prototext input string.
1615    * @param c The object type to create.
1616    * @return The parsed object.
1617    */
1618   public static <T> T proto(String o, Class<T> c) {
1619      return safe(() -> Prototext.to(o, c));
1620   }
1621
1622   /**
1623    * Parses a Protocol Buffers text string to the specified parameterized Java type.
1624    *
1625    * @param <T> The class type of the object being created.
1626    * @param input The Prototext input string.
1627    * @param type The object type to create.
1628    * @param args The type arguments of the class if it's a collection or map.
1629    * @return The parsed object.
1630    * @throws ParseException Malformed input encountered.
1631    */
1632   public static <T> T proto(String input, Type type, Type... args) throws ParseException {
1633      return Prototext.to(input, type, args);
1634   }
1635
1636   //-----------------------------------------------------------------------------------------------------------------
1637   // Binary formats (return byte[])
1638   //-----------------------------------------------------------------------------------------------------------------
1639
1640   /**
1641    * Serializes a Java object to MessagePack bytes.
1642    *
1643    * <p>
1644    * A shortcut for calling <c>MsgPack.<jsm>of</jsm>(<jv>object</jv>)</c>.
1645    *
1646    * @param object The object to serialize.
1647    * @return The serialized object.
1648    * @throws SerializeException If a problem occurred trying to convert the output.
1649    */
1650   public static byte[] msgPack(Object object) throws SerializeException {
1651      return MsgPack.of(object);
1652   }
1653
1654   /**
1655    * Serializes a Java object to the specified MessagePack output.
1656    *
1657    * @param object The object to serialize.
1658    * @param output The output object (OutputStream or File).
1659    * @return The output object.
1660    * @throws SerializeException If a problem occurred trying to convert the output.
1661    * @throws IOException Thrown by underlying stream.
1662    */
1663   public static Object msgPack(Object object, Object output) throws SerializeException, IOException {
1664      MsgPack.DEFAULT.write(object, output); return output;
1665   }
1666
1667   /**
1668    * Parses a MessagePack input to the specified Java type.
1669    *
1670    * @param <T> The class type of the object being created.
1671    * @param input The input (InputStream, byte[], or File).
1672    * @param type The object type to create.
1673    * @return The parsed object.
1674    * @throws ParseException Malformed input encountered.
1675    * @throws IOException Thrown by underlying stream.
1676    */
1677   public static <T> T msgPack(Object input, Class<T> type) throws ParseException, IOException {
1678      return MsgPack.DEFAULT.read(input, type);
1679   }
1680
1681   /**
1682    * Parses a MessagePack input to the specified parameterized Java type.
1683    *
1684    * @param <T> The class type of the object being created.
1685    * @param input The input (InputStream, byte[], or File).
1686    * @param type The object type to create.
1687    * @param args The type arguments of the class if it's a collection or map.
1688    * @return The parsed object.
1689    * @throws ParseException Malformed input encountered.
1690    * @throws IOException Thrown by underlying stream.
1691    */
1692   public static <T> T msgPack(Object input, Type type, Type... args) throws ParseException, IOException {
1693      return MsgPack.DEFAULT.read(input, type, args);
1694   }
1695
1696   /**
1697    * Parses MessagePack bytes to the specified Java type.
1698    *
1699    * @param <T> The class type of the object being created.
1700    * @param o The MessagePack input bytes.
1701    * @param c The object type to create.
1702    * @return The parsed object.
1703    */
1704   public static <T> T msgPack(byte[] o, Class<T> c) {
1705      return safe(() -> MsgPack.to(o, c));
1706   }
1707
1708   /**
1709    * Parses MessagePack bytes to the specified parameterized Java type.
1710    *
1711    * @param <T> The class type of the object being created.
1712    * @param input The MessagePack input bytes.
1713    * @param type The object type to create.
1714    * @param args The type arguments of the class if it's a collection or map.
1715    * @return The parsed object.
1716    * @throws ParseException Malformed input encountered.
1717    */
1718   public static <T> T msgPack(byte[] input, Type type, Type... args) throws ParseException {
1719      return MsgPack.to(input, type, args);
1720   }
1721
1722   /**
1723    * Serializes a Java object to CBOR bytes.
1724    *
1725    * <p>
1726    * A shortcut for calling <c>Cbor.<jsm>of</jsm>(<jv>object</jv>)</c>.
1727    *
1728    * @param object The object to serialize.
1729    * @return The serialized object.
1730    * @throws SerializeException If a problem occurred trying to convert the output.
1731    */
1732   public static byte[] cbor(Object object) throws SerializeException {
1733      return Cbor.of(object);
1734   }
1735
1736   /**
1737    * Serializes a Java object to the specified CBOR output.
1738    *
1739    * @param object The object to serialize.
1740    * @param output The output object (OutputStream or File).
1741    * @return The output object.
1742    * @throws SerializeException If a problem occurred trying to convert the output.
1743    * @throws IOException Thrown by underlying stream.
1744    */
1745   public static Object cbor(Object object, Object output) throws SerializeException, IOException {
1746      Cbor.DEFAULT.write(object, output); return output;
1747   }
1748
1749   /**
1750    * Parses a CBOR input to the specified Java type.
1751    *
1752    * @param <T> The class type of the object being created.
1753    * @param input The input (InputStream, byte[], or File).
1754    * @param type The object type to create.
1755    * @return The parsed object.
1756    * @throws ParseException Malformed input encountered.
1757    * @throws IOException Thrown by underlying stream.
1758    */
1759   public static <T> T cbor(Object input, Class<T> type) throws ParseException, IOException {
1760      return Cbor.DEFAULT.read(input, type);
1761   }
1762
1763   /**
1764    * Parses a CBOR input to the specified parameterized Java type.
1765    *
1766    * @param <T> The class type of the object being created.
1767    * @param input The input (InputStream, byte[], or File).
1768    * @param type The object type to create.
1769    * @param args The type arguments of the class if it's a collection or map.
1770    * @return The parsed object.
1771    * @throws ParseException Malformed input encountered.
1772    * @throws IOException Thrown by underlying stream.
1773    */
1774   public static <T> T cbor(Object input, Type type, Type... args) throws ParseException, IOException {
1775      return Cbor.DEFAULT.read(input, type, args);
1776   }
1777
1778   /**
1779    * Parses CBOR bytes to the specified Java type.
1780    *
1781    * @param <T> The class type of the object being created.
1782    * @param o The CBOR input bytes.
1783    * @param c The object type to create.
1784    * @return The parsed object.
1785    */
1786   public static <T> T cbor(byte[] o, Class<T> c) {
1787      return safe(() -> Cbor.to(o, c));
1788   }
1789
1790   /**
1791    * Parses CBOR bytes to the specified parameterized Java type.
1792    *
1793    * @param <T> The class type of the object being created.
1794    * @param input The CBOR input bytes.
1795    * @param type The object type to create.
1796    * @param args The type arguments of the class if it's a collection or map.
1797    * @return The parsed object.
1798    * @throws ParseException Malformed input encountered.
1799    */
1800   public static <T> T cbor(byte[] input, Type type, Type... args) throws ParseException {
1801      return Cbor.to(input, type, args);
1802   }
1803
1804   /**
1805    * Serializes a Java object to BSON bytes.
1806    *
1807    * <p>
1808    * A shortcut for calling <c>Bson.<jsm>of</jsm>(<jv>object</jv>)</c>.
1809    *
1810    * @param object The object to serialize.
1811    * @return The serialized object.
1812    * @throws SerializeException If a problem occurred trying to convert the output.
1813    */
1814   public static byte[] bson(Object object) throws SerializeException {
1815      return Bson.of(object);
1816   }
1817
1818   /**
1819    * Serializes a Java object to the specified BSON output.
1820    *
1821    * @param object The object to serialize.
1822    * @param output The output object (OutputStream or File).
1823    * @return The output object.
1824    * @throws SerializeException If a problem occurred trying to convert the output.
1825    * @throws IOException Thrown by underlying stream.
1826    */
1827   public static Object bson(Object object, Object output) throws SerializeException, IOException {
1828      Bson.DEFAULT.write(object, output); return output;
1829   }
1830
1831   /**
1832    * Parses a BSON input to the specified Java type.
1833    *
1834    * @param <T> The class type of the object being created.
1835    * @param input The input (InputStream, byte[], or File).
1836    * @param type The object type to create.
1837    * @return The parsed object.
1838    * @throws ParseException Malformed input encountered.
1839    * @throws IOException Thrown by underlying stream.
1840    */
1841   public static <T> T bson(Object input, Class<T> type) throws ParseException, IOException {
1842      return Bson.DEFAULT.read(input, type);
1843   }
1844
1845   /**
1846    * Parses a BSON input to the specified parameterized Java type.
1847    *
1848    * @param <T> The class type of the object being created.
1849    * @param input The input (InputStream, byte[], or File).
1850    * @param type The object type to create.
1851    * @param args The type arguments of the class if it's a collection or map.
1852    * @return The parsed object.
1853    * @throws ParseException Malformed input encountered.
1854    * @throws IOException Thrown by underlying stream.
1855    */
1856   public static <T> T bson(Object input, Type type, Type... args) throws ParseException, IOException {
1857      return Bson.DEFAULT.read(input, type, args);
1858   }
1859
1860   /**
1861    * Parses BSON bytes to the specified Java type.
1862    *
1863    * @param <T> The class type of the object being created.
1864    * @param o The BSON input bytes.
1865    * @param c The object type to create.
1866    * @return The parsed object.
1867    */
1868   public static <T> T bson(byte[] o, Class<T> c) {
1869      return safe(() -> Bson.to(o, c));
1870   }
1871
1872   /**
1873    * Parses BSON bytes to the specified parameterized Java type.
1874    *
1875    * @param <T> The class type of the object being created.
1876    * @param input The BSON input bytes.
1877    * @param type The object type to create.
1878    * @param args The type arguments of the class if it's a collection or map.
1879    * @return The parsed object.
1880    * @throws ParseException Malformed input encountered.
1881    */
1882   public static <T> T bson(byte[] input, Type type, Type... args) throws ParseException {
1883      return Bson.to(input, type, args);
1884   }
1885
1886   /**
1887    * Serializes a Java object to Apache Parquet bytes.
1888    *
1889    * <p>
1890    * A shortcut for calling <c>Parquet.<jsm>of</jsm>(<jv>object</jv>)</c>.
1891    *
1892    * <p class='warnbox'>
1893    *    <b>Note:</b> Parquet is collection-oriented. A single bean is automatically wrapped in a one-element list.
1894    * </p>
1895    *
1896    * @param object The object to serialize (Collection, array, or single bean).
1897    * @return The serialized object.
1898    * @throws SerializeException If a problem occurred trying to convert the output.
1899    */
1900   public static byte[] parquet(Object object) throws SerializeException {
1901      return Parquet.of(object);
1902   }
1903
1904   /**
1905    * Serializes a Java object to the specified Parquet output.
1906    *
1907    * @param object The object to serialize.
1908    * @param output The output object (OutputStream or File).
1909    * @return The output object.
1910    * @throws SerializeException If a problem occurred trying to convert the output.
1911    * @throws IOException Thrown by underlying stream.
1912    */
1913   public static Object parquet(Object object, Object output) throws SerializeException, IOException {
1914      Parquet.DEFAULT.write(object, output); return output;
1915   }
1916
1917   /**
1918    * Parses a Parquet input to a list of the specified Java type.
1919    *
1920    * <p class='warnbox'>
1921    *    <b>Note:</b> Parquet always returns a {@link List}; the parser never returns a bare instance.
1922    * </p>
1923    *
1924    * @param <T> The element type.
1925    * @param input The input (InputStream, byte[], or File).
1926    * @param type The bean class (parser returns {@code List<T>}).
1927    * @return The parsed list of beans.
1928    * @throws ParseException Malformed input encountered.
1929    * @throws IOException Thrown by underlying stream.
1930    */
1931   public static <T> List<T> parquet(Object input, Class<T> type) throws ParseException, IOException {
1932      return (List<T>) Parquet.DEFAULT.read(input, List.class, type);
1933   }
1934
1935   /**
1936    * Parses Apache Parquet bytes to a list of the specified Java type.
1937    *
1938    * <p class='warnbox'>
1939    *    <b>Note:</b> Parquet always returns a {@link List}; the parser never returns a bare instance.
1940    * </p>
1941    *
1942    * @param <T> The element type.
1943    * @param o The Parquet input bytes.
1944    * @param c The bean class (parser returns {@code List<T>}).
1945    * @return The parsed list of beans.
1946    */
1947   public static <T> List<T> parquet(byte[] o, Class<T> c) {
1948      return (List<T>) safe(() -> Parquet.to(o, List.class, c));
1949   }
1950
1951   /**
1952    * Parses Apache Parquet bytes to a list of the specified element type.
1953    *
1954    * @param <T> The element type.
1955    * @param input The Parquet input bytes.
1956    * @param type The element type (parser returns {@code List<T>}).
1957    * @return The parsed list.
1958    * @throws ParseException Malformed input encountered.
1959    */
1960   public static <T> List<T> parquet(byte[] input, Type type) throws ParseException {
1961      return (List<T>) Parquet.to(input, List.class, type);
1962   }
1963
1964   /**
1965    * Parses Apache Parquet bytes to the specified parameterized Java type.
1966    *
1967    * @param <T> The class type of the object being created.
1968    * @param input The Parquet input bytes.
1969    * @param type The object type to create.
1970    * @param args The type arguments of the class if it's a collection or map.
1971    * @return The parsed object.
1972    * @throws ParseException Malformed input encountered.
1973    */
1974   public static <T> T parquet(byte[] input, Type type, Type... args) throws ParseException {
1975      return Parquet.to(input, type, args);
1976   }
1977}