001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.serializer;
014
015import static org.apache.juneau.serializer.Serializer.*;
016
017import java.lang.annotation.*;
018import java.lang.reflect.*;
019import java.util.*;
020
021import org.apache.juneau.*;
022import org.apache.juneau.annotation.*;
023import org.apache.juneau.http.*;
024import org.apache.juneau.internal.*;
025import org.apache.juneau.reflect.*;
026import org.apache.juneau.svl.*;
027
028/**
029 * Builder class for building instances of serializers.
030 */
031public class SerializerBuilder extends BeanTraverseBuilder {
032
033   /**
034    * Constructor, default settings.
035    */
036   public SerializerBuilder() {
037      super();
038   }
039
040   /**
041    * Constructor.
042    *
043    * @param ps The initial configuration settings for this builder.
044    */
045   public SerializerBuilder(PropertyStore ps) {
046      super(ps);
047   }
048
049   //-----------------------------------------------------------------------------------------------------------------
050   // Properties
051   //-----------------------------------------------------------------------------------------------------------------
052
053   /**
054    * <i><l>Serializer</l> configuration property:&emsp;</i>  Add <js>"_type"</js> properties when needed.
055    *
056    * <div class='warn'>
057    *    <b>Deprecated</b> - Use {@link #addBeanTypes()}
058    * </div>
059    */
060   @SuppressWarnings("javadoc")
061   @FluentSetter
062   @Deprecated
063   public SerializerBuilder addBeanTypes(boolean value) {
064      return set(SERIALIZER_addBeanTypes, value);
065   }
066
067   /**
068    * <i><l>Serializer</l> configuration property:&emsp;</i>  Add <js>"_type"</js> properties when needed.
069    *
070    * <p>
071    * When enabled, <js>"_type"</js> properties will be added to beans if their type cannot be inferred
072    * through reflection.
073    *
074    * <p>
075    * This is used to recreate the correct objects during parsing if the object types cannot be inferred.
076    * <br>For example, when serializing a <c>Map&lt;String,Object&gt;</c> field where the bean class cannot be determined from
077    * the type of the values.
078    *
079    * <p>
080    * Note the differences between the following settings:
081    * <ul class='javatree'>
082    *    <li class='jf'>{@link #addRootType()} - Affects whether <js>'_type'</js> is added to root node.
083    *    <li class='jf'>{@link #addBeanTypes()} - Affects whether <js>'_type'</js> is added to any nodes.
084    * </ul>
085    *
086    * <h5 class='section'>Example:</h5>
087    * <p class='bcode w800'>
088    *    <jc>// Create a serializer that adds _type to nodes.</jc>
089    *    WriterSerializer s = JsonSerializer
090    *       .<jsm>create</jsm>()
091    *       .addBeanTypes()
092    *       .build();
093    *
094    *    <jc>// Our map of beans to serialize.</jc>
095    *    <ja>@Bean</ja>(typeName=<js>"mybean"</js>)
096    *    <jk>public class</jk> MyBean {
097    *       <jk>public</jk> String <jf>foo</jf> = <js>"bar"</js>;
098    *    }
099    *    OMap map = OMap.of(<js>"foo"</js>, <jk>new</jk> MyBean());
100    *
101    *    <jc>// Will contain:  {"foo":{"_type":"mybean","foo":"bar"}}</jc>
102    *    String json = s.serialize(map);
103    * </p>
104    *
105    * <ul class='seealso'>
106    *    <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypes}
107    * </ul>
108    *
109    * @return This object (for method chaining).
110    */
111   @FluentSetter
112   public SerializerBuilder addBeanTypes() {
113      return set(SERIALIZER_addBeanTypes, true);
114   }
115
116   /**
117    * <i><l>Serializer</l> configuration property:&emsp;</i>  Add type attribute to root nodes.
118    *
119    * <div class='warn'>
120    *    <b>Deprecated</b> - Use {@link #addRootType()}
121    * </div>
122    */
123   @SuppressWarnings("javadoc")
124   @FluentSetter
125   @Deprecated
126   public SerializerBuilder addRootType(boolean value) {
127      return set(SERIALIZER_addRootType, value);
128   }
129
130   /**
131    * <i><l>Serializer</l> configuration property:&emsp;</i>  Add type attribute to root nodes.
132    *
133    * <p>
134    * When enabled, <js>"_type"</js> properties will be added to top-level beans.
135    *
136    * <p>
137    * When disabled, it is assumed that the parser knows the exact Java POJO type being parsed, and therefore top-level
138    * type information that might normally be included to determine the data type will not be serialized.
139    *
140    * <p>
141    * For example, when serializing a top-level POJO with a {@link Bean#typeName() @Bean(typeName)} value, a
142    * <js>'_type'</js> attribute will only be added when this setting is enabled.
143    *
144    * <p>
145    * Note the differences between the following settings:
146    * <ul class='javatree'>
147    *    <li class='jf'>{@link #addRootType()} - Affects whether <js>'_type'</js> is added to root node.
148    *    <li class='jf'>{@link #addBeanTypes()} - Affects whether <js>'_type'</js> is added to any nodes.
149    * </ul>
150    *
151    * <h5 class='section'>Example:</h5>
152    * <p class='bcode w800'>
153    *    <jc>// Create a serializer that adds _type to root node.</jc>
154    *    WriterSerializer s = JsonSerializer
155    *       .<jsm>create</jsm>()
156    *       .addRootType()
157    *       .build();
158    *
159    *    <jc>// Our bean to serialize.</jc>
160    *    <ja>@Bean</ja>(typeName=<js>"mybean"</js>)
161    *    <jk>public class</jk> MyBean {
162    *       <jk>public</jk> String <jf>foo</jf> = <js>"bar"</js>;
163    *    }
164    *
165    *    <jc>// Will contain:  {"_type":"mybean","foo":"bar"}</jc>
166    *    String json = s.serialize(<jk>new</jk> MyBean());
167    * </p>
168    *
169    * <ul class='seealso'>
170    *    <li class='jf'>{@link Serializer#SERIALIZER_addRootType}
171    * </ul>
172    *
173    * @return This object (for method chaining).
174    */
175   @FluentSetter
176   public SerializerBuilder addRootType() {
177      return set(SERIALIZER_addRootType, true);
178   }
179
180   /**
181    * <i><l>Serializer</l> configuration property:&emsp;</i>  Don't trim null bean property values.
182    *
183    * <div class='warn'>
184    *    <b>Deprecated</b> - Use {@link #keepNullProperties()}
185    * </div>
186    */
187   @SuppressWarnings("javadoc")
188   @FluentSetter
189   @Deprecated
190   public SerializerBuilder keepNullProperties(boolean value) {
191      return set(SERIALIZER_keepNullProperties, value);
192   }
193
194   /**
195    * <i><l>Serializer</l> configuration property:&emsp;</i>  Don't trim null bean property values.
196    *
197    * <p>
198    * When enabled, null bean values will be serialized to the output.
199    *
200    * <ul class='notes'>
201    *    <li>Not enabling this setting will cause <c>Map</c>s with <jk>null</jk> values to be lost during parsing.
202    * </ul>
203    *
204    * <h5 class='section'>Example:</h5>
205    * <p class='bcode w800'>
206    *    <jc>// Create a serializer that serializes null properties.</jc>
207    *    WriterSerializer s = JsonSerializer
208    *       .<jsm>create</jsm>()
209    *       .keepNullProperties()
210    *       .build();
211    *
212    *    <jc>// Our bean to serialize.</jc>
213    *    <jk>public class</jk> MyBean {
214    *       <jk>public</jk> String <jf>foo</jf> = <jk>null</jk>;
215    *    }
216    *
217    *    <jc>// Will contain "{foo:null}".</jc>
218    *    String json = s.serialize(<jk>new</jk> MyBean());
219    * </p>
220    *
221    * <ul class='seealso'>
222    *    <li class='jf'>{@link Serializer#SERIALIZER_keepNullProperties}
223    * </ul>
224    *
225    * @return This object (for method chaining).
226    */
227   @FluentSetter
228   public SerializerBuilder keepNullProperties() {
229      return set(SERIALIZER_keepNullProperties, true);
230   }
231
232   /**
233    * <i><l>Serializer</l> configuration property:&emsp;</i>  Serializer listener.
234    *
235    * <p>
236    * Class used to listen for errors and warnings that occur during serialization.
237    *
238    * <h5 class='section'>Example:</h5>
239    * <p class='bcode w800'>
240    *    <jc>// Define our serializer listener.</jc>
241    *    <jc>// Simply captures all errors.</jc>
242    *    <jk>public class</jk> MySerializerListener <jk>extends</jk> SerializerListener {
243    *
244    *       <jc>// A simple property to store our events.</jc>
245    *       <jk>public</jk> List&lt;String&gt; <jf>events</jf> = <jk>new</jk> LinkedList&lt;&gt;();
246    *
247    *       <ja>@Override</ja>
248    *       <jk>public</jk> &lt;T&gt; <jk>void</jk> onError(SerializerSession session, Throwable t, String msg) {
249    *          <jf>events</jf>.add(session.getLastLocation() + <js>","</js> + msg + <js>","</js> + t);
250    *       }
251    *    }
252    *
253    *    <jc>// Create a serializer using our listener.</jc>
254    *    WriterSerializer s = JsonSerializer
255    *       .<jsm>create</jsm>()
256    *       .listener(MySerializerListener.<jk>class</jk>)
257    *       .build();
258    *
259    *    <jc>// Create a session object.</jc>
260    *    <jc>// Needed because listeners are created per-session.</jc>
261    *    <jk>try</jk> (WriterSerializerSession ss = s.createSession()) {
262    *
263    *       <jc>// Serialize a bean.</jc>
264    *       String json = ss.serialize(<jk>new</jk> MyBean());
265    *
266    *       <jc>// Get the listener.</jc>
267    *       MySerializerListener l = ss.getListener(MySerializerListener.<jk>class</jk>);
268    *
269    *       <jc>// Dump the results to the console.</jc>
270    *       SimpleJsonSerializer.<jsf>DEFAULT</jsf>.println(l.<jf>events</jf>);
271    *    }
272    * </p>
273    *
274    * <ul class='seealso'>
275    *    <li class='jf'>{@link Serializer#SERIALIZER_listener}
276    * </ul>
277    *
278    * @param value
279    *    The new value for this property.
280    * @return This object (for method chaining).
281    */
282   @FluentSetter
283   public SerializerBuilder listener(Class<? extends SerializerListener> value) {
284      return set(SERIALIZER_listener, value);
285   }
286
287   /**
288    * <i><l>Serializer</l> configuration property:&emsp;</i>  Sort arrays and collections alphabetically.
289    *
290    * <div class='warn'>
291    *    <b>Deprecated</b> - Use {@link #sortCollections()}
292    * </div>
293    */
294   @SuppressWarnings("javadoc")
295   @FluentSetter
296   @Deprecated
297   public SerializerBuilder sortCollections(boolean value) {
298      return set(SERIALIZER_sortCollections, value);
299   }
300
301   /**
302    * <i><l>Serializer</l> configuration property:&emsp;</i>  Sort arrays and collections alphabetically.
303    *
304    * <p>
305    * When enabled, copies and sorts the contents of arrays and collections before serializing them.
306    *
307    * <p>
308    * Note that this introduces a performance penalty since it requires copying the existing collection.
309    *
310    * <h5 class='section'>Example:</h5>
311    * <p class='bcode w800'>
312    *    <jc>// Create a serializer that sorts arrays and collections before serialization.</jc>
313    *    WriterSerializer s = JsonSerializer
314    *       .<jsm>create</jsm>()
315    *       .sortCollections()
316    *       .build();
317    *
318    *    <jc>// An unsorted array</jc>
319    *    String[] array = {<js>"foo"</js>,<js>"bar"</js>,<js>"baz"</js>}
320    *
321    *    <jc>// Produces ["bar","baz","foo"]</jc>
322    *    String json = s.serialize(array);
323    * </p>
324    *
325    * <ul class='seealso'>
326    *    <li class='jf'>{@link Serializer#SERIALIZER_sortCollections}
327    * </ul>
328    *
329    * @return This object (for method chaining).
330    */
331   @FluentSetter
332   public SerializerBuilder sortCollections() {
333      return set(SERIALIZER_sortCollections, true);
334   }
335
336   /**
337    * <i><l>Serializer</l> configuration property:&emsp;</i>  Sort maps alphabetically.
338    *
339    * <div class='warn'>
340    *    <b>Deprecated</b> - Use {@link #sortMaps()}
341    * </div>
342    */
343   @SuppressWarnings("javadoc")
344   @FluentSetter
345   @Deprecated
346   public SerializerBuilder sortMaps(boolean value) {
347      return set(SERIALIZER_sortMaps, value);
348   }
349
350   /**
351    * <i><l>Serializer</l> configuration property:&emsp;</i>  Sort maps alphabetically.
352    *
353    * <p>
354    * When enabled, copies and sorts the contents of maps by their keys before serializing them.
355    *
356    * <p>
357    * Note that this introduces a performance penalty.
358    *
359    * <h5 class='section'>Example:</h5>
360    * <p class='bcode w800'>
361    *    <jc>// Create a serializer that sorts maps before serialization.</jc>
362    *    WriterSerializer s = JsonSerializer
363    *       .<jsm>create</jsm>()
364    *       .sortMaps()
365    *       .build();
366    *
367    *    <jc>// An unsorted map.</jc>
368    *    OMap map = OMap.<jsm>of</jsm>(<js>"foo"</js>,1,<js>"bar"</js>,2,<js>"baz"</js>,3);
369    *
370    *    <jc>// Produces {"bar":2,"baz":3,"foo":1}</jc>
371    *    String json = s.serialize(map);
372    * </p>
373    *
374    * <ul class='seealso'>
375    *    <li class='jf'>{@link Serializer#SERIALIZER_sortMaps}
376    * </ul>
377    *
378    * @return This object (for method chaining).
379    */
380   @FluentSetter
381   public SerializerBuilder sortMaps() {
382      return set(SERIALIZER_sortMaps, true);
383   }
384
385   /**
386    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim empty lists and arrays.
387    *
388    * <div class='warn'>
389    *    <b>Deprecated</b> - Use {@link #trimEmptyCollections()}
390    * </div>
391    */
392   @SuppressWarnings("javadoc")
393   @FluentSetter
394   @Deprecated
395   public SerializerBuilder trimEmptyCollections(boolean value) {
396      return set(SERIALIZER_trimEmptyCollections, value);
397   }
398
399   /**
400    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim empty lists and arrays.
401    *
402    * <p>
403    * When enabled, empty lists and arrays will not be serialized.
404    *
405    * <p>
406    * Note that enabling this setting has the following effects on parsing:
407    * <ul class='spaced-list'>
408    *    <li>
409    *       Map entries with empty list values will be lost.
410    *    <li>
411    *       Bean properties with empty list values will not be set.
412    * </ul>
413    *
414    * <h5 class='section'>Example:</h5>
415    * <p class='bcode w800'>
416    *    <jc>// Create a serializer that skips empty arrays and collections.</jc>
417    *    WriterSerializer s = JsonSerializer
418    *       .<jsm>create</jsm>()
419    *       .trimEmptyCollections()
420    *       .build();
421    *
422    *    <jc>// A bean with a field with an empty array.</jc>
423    *    <jk>public class</jk> MyBean {
424    *       <jk>public</jk> String[] <jf>foo</jf> = {};
425    *    }
426    *
427    *    <jc>// Produces {}</jc>
428    *    String json = s.serialize(<jk>new</jk> MyBean());
429    * </p>
430    *
431    * <ul class='seealso'>
432    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections}
433    * </ul>
434    *
435    * @return This object (for method chaining).
436    */
437   @FluentSetter
438   public SerializerBuilder trimEmptyCollections() {
439      return set(SERIALIZER_trimEmptyCollections, true);
440   }
441
442   /**
443    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim empty maps.
444    *
445    * <div class='warn'>
446    *    <b>Deprecated</b> - Use {@link #trimEmptyMaps()}
447    * </div>
448    */
449   @SuppressWarnings("javadoc")
450   @FluentSetter
451   @Deprecated
452   public SerializerBuilder trimEmptyMaps(boolean value) {
453      return set(SERIALIZER_trimEmptyMaps, value);
454   }
455
456   /**
457    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim empty maps.
458    *
459    * <p>
460    * When enabled, empty map values will not be serialized to the output.
461    *
462    * <p>
463    * Note that enabling this setting has the following effects on parsing:
464    * <ul class='spaced-list'>
465    *    <li>
466    *       Bean properties with empty map values will not be set.
467    * </ul>
468    *
469    * <h5 class='section'>Example:</h5>
470    * <p class='bcode w800'>
471    *    <jc>// Create a serializer that skips empty maps.</jc>
472    *    WriterSerializer s = JsonSerializer
473    *       .<jsm>create</jsm>()
474    *       .trimEmptyMaps()
475    *       .build();
476    *
477    *    <jc>// A bean with a field with an empty map.</jc>
478    *    <jk>public class</jk> MyBean {
479    *       <jk>public</jk> OMap <jf>foo</jf> = OMap.<jsm>of</jsm>();
480    *    }
481    *
482    *    <jc>// Produces {}</jc>
483    *    String json = s.serialize(<jk>new</jk> MyBean());
484    * </p>
485    *
486    * <ul class='seealso'>
487    *    <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps}
488    * </ul>
489    *
490    * @return This object (for method chaining).
491    */
492   @FluentSetter
493   public SerializerBuilder trimEmptyMaps() {
494      return set(SERIALIZER_trimEmptyMaps, true);
495   }
496
497   /**
498    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim null bean property values.
499    *
500    * <div class='warn'>
501    *    <b>Deprecated</b> - Use {@link #keepNullProperties()}
502    * </div>
503    */
504   @SuppressWarnings("javadoc")
505   @FluentSetter
506   @Deprecated
507   public SerializerBuilder trimNullProperties(boolean value) {
508      return set(SERIALIZER_trimNullProperties, value);
509   }
510
511   /**
512    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim null bean property values.
513    *
514    * <div class='warn'>
515    *    <b>Deprecated</b> - Use {@link #keepNullProperties()}
516    * </div>
517    */
518   @SuppressWarnings("javadoc")
519   @FluentSetter
520   @Deprecated
521   public SerializerBuilder dontTrimNullProperties() {
522      return set(SERIALIZER_trimNullProperties, false);
523   }
524
525   /**
526    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim strings.
527    *
528    * <div class='warn'>
529    *    <b>Deprecated</b> - Use {@link #trimStrings()}
530    * </div>
531    */
532   @SuppressWarnings("javadoc")
533   @FluentSetter
534   @Deprecated
535   public SerializerBuilder trimStrings(boolean value) {
536      return set(SERIALIZER_trimStrings, value);
537   }
538
539   /**
540    * <i><l>Serializer</l> configuration property:&emsp;</i>  Trim strings.
541    *
542    * <p>
543    * When enabled, string values will be trimmed of whitespace using {@link String#trim()} before being serialized.
544    *
545    * <h5 class='section'>Example:</h5>
546    * <p class='bcode w800'>
547    *    <jc>// Create a serializer that trims strings before serialization.</jc>
548    *    WriterSerializer s = JsonSerializer
549    *       .<jsm>create</jsm>()
550    *       .trimStrings()
551    *       .build();
552    *
553    * <jc>// A map with space-padded keys/values</jc>
554    *    OMap map = OMap.<jsm>of</jsm>(<js>" foo "</js>, <js>" bar "</js>);
555    *
556    *    <jc>// Produces "{foo:'bar'}"</jc>
557    *    String json = s.toString(map);
558    * </p>
559    *
560    * <ul class='seealso'>
561    *    <li class='jf'>{@link Serializer#SERIALIZER_trimStrings}
562    * </ul>
563    *
564    * @return This object (for method chaining).
565    */
566   @FluentSetter
567   public SerializerBuilder trimStrings() {
568      return set(SERIALIZER_trimStrings, true);
569   }
570
571   /**
572    * <i><l>Serializer</l> configuration property:&emsp;</i>  URI context bean.
573    *
574    * <p>
575    * Bean used for resolution of URIs to absolute or root-relative form.
576    *
577    * <h5 class='section'>Example:</h5>
578    * <p class='bcode w800'>
579    *    <jc>// Our URI contextual information.</jc>
580    *    String authority = <js>"http://localhost:10000"</js>;
581    *    String contextRoot = <js>"/myContext"</js>;
582    *    String servletPath = <js>"/myServlet"</js>;
583    *    String pathInfo = <js>"/foo"</js>;
584    *
585    *    <jc>// Create a UriContext object.</jc>
586    *    UriContext uriContext = <jk>new</jk> UriContext(authority, contextRoot, servletPath, pathInfo);
587    *
588    *    <jc>// Associate it with our serializer.</jc>
589    *    WriterSerializer s = JsonSerializer
590    *       .<jsm>create</jsm>()
591    *       .uriContext(uriContext)
592    *       .uriRelativity(<jsf>RESOURCE</jsf>)  <jc>// Assume relative paths are relative to servlet.</jc>
593    *       .uriResolution(<jsf>ABSOLUTE</jsf>)  <jc>// Serialize URLs as absolute paths.</jc>
594    *       .build();
595    *
596    *    <jc>// A relative URL</jc>
597    *    URL url = <jk>new</jk> URL(<js>"bar"</js>);
598    *
599    *    <jc>// Produces "http://localhost:10000/myContext/myServlet/foo/bar"</jc>
600    *    String json = s.toString(url);
601    * </p>
602    *
603    * <ul class='seealso'>
604    *    <li class='jf'>{@link Serializer#SERIALIZER_uriContext}
605    *    <li class='link'>{@doc MarshallingUris}
606    * </ul>
607    *
608    * @param value The new value for this property.
609    * @return This object (for method chaining).
610    */
611   @FluentSetter
612   public SerializerBuilder uriContext(UriContext value) {
613      return set(SERIALIZER_uriContext, value);
614   }
615
616   /**
617    * <i><l>Serializer</l> configuration property:&emsp;</i>  URI relativity.
618    *
619    * <p>
620    * Defines what relative URIs are relative to when serializing any of the following:
621    * <ul>
622    *    <li>{@link java.net.URI}
623    *    <li>{@link java.net.URL}
624    *    <li>Properties and classes annotated with {@link org.apache.juneau.annotation.URI @URI}
625    * </ul>
626    *
627    * <p>
628    * Possible values are:
629    * <ul class='javatree'>
630    *    <li class='jf'>{@link org.apache.juneau.UriRelativity#RESOURCE}
631    *       - Relative URIs should be considered relative to the servlet URI.
632    *    <li class='jf'>{@link org.apache.juneau.UriRelativity#PATH_INFO}
633    *       - Relative URIs should be considered relative to the request URI.
634    * </ul>
635    *
636    * <p>
637    * See {@link #uriContext(UriContext)} for examples.
638    *
639    * <ul class='seealso'>
640    *    <li class='jf'>{@link Serializer#SERIALIZER_uriRelativity}
641    *    <li class='link'>{@doc MarshallingUris}
642    * </ul>
643    *
644    * @param value
645    *    The new value for this property.
646    *    <br>The default is {@link UriRelativity#RESOURCE}
647    * @return This object (for method chaining).
648    */
649   @FluentSetter
650   public SerializerBuilder uriRelativity(UriRelativity value) {
651      return set(SERIALIZER_uriRelativity, value);
652   }
653
654   /**
655    * <i><l>Serializer</l> configuration property:&emsp;</i>  URI resolution.
656    *
657    * <p>
658    * Defines the resolution level for URIs when serializing any of the following:
659    * <ul>
660    *    <li>{@link java.net.URI}
661    *    <li>{@link java.net.URL}
662    *    <li>Properties and classes annotated with {@link org.apache.juneau.annotation.URI @URI}
663    * </ul>
664    *
665    * <p>
666    * Possible values are:
667    * <ul>
668    *    <li class='jf'>{@link UriResolution#ABSOLUTE}
669    *       - Resolve to an absolute URL (e.g. <js>"http://host:port/context-root/servlet-path/path-info"</js>).
670    *    <li class='jf'>{@link UriResolution#ROOT_RELATIVE}
671    *       - Resolve to a root-relative URL (e.g. <js>"/context-root/servlet-path/path-info"</js>).
672    *    <li class='jf'>{@link UriResolution#NONE}
673    *       - Don't do any URL resolution.
674    * </ul>
675    *
676    * <p>
677    * See {@link #uriContext(UriContext)} for examples.
678    *
679    * <ul class='seealso'>
680    *    <li class='jf'>{@link Serializer#SERIALIZER_uriResolution}
681    *    <li class='link'>{@doc MarshallingUris}
682    * </ul>
683    *
684    * @param value
685    *    The new value for this property.
686    *    <br>The default is {@link UriResolution#NONE}
687    * @return This object (for method chaining).
688    */
689   @FluentSetter
690   public SerializerBuilder uriResolution(UriResolution value) {
691      return set(SERIALIZER_uriResolution, value);
692   }
693
694   // <FluentSetters>
695
696   @Override /* GENERATED - ContextBuilder */
697   public SerializerBuilder add(Map<String,Object> properties) {
698      super.add(properties);
699      return this;
700   }
701
702   @Override /* GENERATED - ContextBuilder */
703   public SerializerBuilder addTo(String name, Object value) {
704      super.addTo(name, value);
705      return this;
706   }
707
708   @Override /* GENERATED - ContextBuilder */
709   public SerializerBuilder appendTo(String name, Object value) {
710      super.appendTo(name, value);
711      return this;
712   }
713
714   @Override /* GENERATED - ContextBuilder */
715   public SerializerBuilder apply(PropertyStore copyFrom) {
716      super.apply(copyFrom);
717      return this;
718   }
719
720   @Override /* GENERATED - ContextBuilder */
721   public SerializerBuilder applyAnnotations(java.lang.Class<?>...fromClasses) {
722      super.applyAnnotations(fromClasses);
723      return this;
724   }
725
726   @Override /* GENERATED - ContextBuilder */
727   public SerializerBuilder applyAnnotations(Method...fromMethods) {
728      super.applyAnnotations(fromMethods);
729      return this;
730   }
731
732   @Override /* GENERATED - ContextBuilder */
733   public SerializerBuilder applyAnnotations(AnnotationList al, VarResolverSession r) {
734      super.applyAnnotations(al, r);
735      return this;
736   }
737
738   @Override /* GENERATED - ContextBuilder */
739   public SerializerBuilder debug() {
740      super.debug();
741      return this;
742   }
743
744   @Override /* GENERATED - ContextBuilder */
745   public SerializerBuilder locale(Locale value) {
746      super.locale(value);
747      return this;
748   }
749
750   @Override /* GENERATED - ContextBuilder */
751   public SerializerBuilder mediaType(MediaType value) {
752      super.mediaType(value);
753      return this;
754   }
755
756   @Override /* GENERATED - ContextBuilder */
757   public SerializerBuilder prependTo(String name, Object value) {
758      super.prependTo(name, value);
759      return this;
760   }
761
762   @Override /* GENERATED - ContextBuilder */
763   public SerializerBuilder putAllTo(String name, Object value) {
764      super.putAllTo(name, value);
765      return this;
766   }
767
768   @Override /* GENERATED - ContextBuilder */
769   public SerializerBuilder putTo(String name, String key, Object value) {
770      super.putTo(name, key, value);
771      return this;
772   }
773
774   @Override /* GENERATED - ContextBuilder */
775   public SerializerBuilder removeFrom(String name, Object value) {
776      super.removeFrom(name, value);
777      return this;
778   }
779
780   @Override /* GENERATED - ContextBuilder */
781   public SerializerBuilder set(Map<String,Object> properties) {
782      super.set(properties);
783      return this;
784   }
785
786   @Override /* GENERATED - ContextBuilder */
787   public SerializerBuilder set(String name, Object value) {
788      super.set(name, value);
789      return this;
790   }
791
792   @Override /* GENERATED - ContextBuilder */
793   public SerializerBuilder timeZone(TimeZone value) {
794      super.timeZone(value);
795      return this;
796   }
797
798   @Override /* GENERATED - BeanContextBuilder */
799   public SerializerBuilder annotations(Annotation...values) {
800      super.annotations(values);
801      return this;
802   }
803
804   @Override /* GENERATED - BeanContextBuilder */
805   public SerializerBuilder beanClassVisibility(Visibility value) {
806      super.beanClassVisibility(value);
807      return this;
808   }
809
810   @Override /* GENERATED - BeanContextBuilder */
811   public SerializerBuilder beanConstructorVisibility(Visibility value) {
812      super.beanConstructorVisibility(value);
813      return this;
814   }
815
816   @Override /* GENERATED - BeanContextBuilder */
817   public SerializerBuilder beanFieldVisibility(Visibility value) {
818      super.beanFieldVisibility(value);
819      return this;
820   }
821
822   @Override /* GENERATED - BeanContextBuilder */
823   public SerializerBuilder beanInterceptor(Class<?> on, Class<? extends org.apache.juneau.transform.BeanInterceptor<?>> value) {
824      super.beanInterceptor(on, value);
825      return this;
826   }
827
828   @Override /* GENERATED - BeanContextBuilder */
829   public SerializerBuilder beanMapPutReturnsOldValue() {
830      super.beanMapPutReturnsOldValue();
831      return this;
832   }
833
834   @Override /* GENERATED - BeanContextBuilder */
835   public SerializerBuilder beanMethodVisibility(Visibility value) {
836      super.beanMethodVisibility(value);
837      return this;
838   }
839
840   @Override /* GENERATED - BeanContextBuilder */
841   public SerializerBuilder beansDontRequireSomeProperties() {
842      super.beansDontRequireSomeProperties();
843      return this;
844   }
845
846   @Override /* GENERATED - BeanContextBuilder */
847   public SerializerBuilder beansRequireDefaultConstructor() {
848      super.beansRequireDefaultConstructor();
849      return this;
850   }
851
852   @Override /* GENERATED - BeanContextBuilder */
853   public SerializerBuilder beansRequireSerializable() {
854      super.beansRequireSerializable();
855      return this;
856   }
857
858   @Override /* GENERATED - BeanContextBuilder */
859   public SerializerBuilder beansRequireSettersForGetters() {
860      super.beansRequireSettersForGetters();
861      return this;
862   }
863
864   @Override /* GENERATED - BeanContextBuilder */
865   public SerializerBuilder bpi(Map<String,Object> values) {
866      super.bpi(values);
867      return this;
868   }
869
870   @Override /* GENERATED - BeanContextBuilder */
871   public SerializerBuilder bpi(Class<?> beanClass, String properties) {
872      super.bpi(beanClass, properties);
873      return this;
874   }
875
876   @Override /* GENERATED - BeanContextBuilder */
877   public SerializerBuilder bpi(String beanClassName, String properties) {
878      super.bpi(beanClassName, properties);
879      return this;
880   }
881
882   @Override /* GENERATED - BeanContextBuilder */
883   public SerializerBuilder bpro(Map<String,Object> values) {
884      super.bpro(values);
885      return this;
886   }
887
888   @Override /* GENERATED - BeanContextBuilder */
889   public SerializerBuilder bpro(Class<?> beanClass, String properties) {
890      super.bpro(beanClass, properties);
891      return this;
892   }
893
894   @Override /* GENERATED - BeanContextBuilder */
895   public SerializerBuilder bpro(String beanClassName, String properties) {
896      super.bpro(beanClassName, properties);
897      return this;
898   }
899
900   @Override /* GENERATED - BeanContextBuilder */
901   public SerializerBuilder bpwo(Map<String,Object> values) {
902      super.bpwo(values);
903      return this;
904   }
905
906   @Override /* GENERATED - BeanContextBuilder */
907   public SerializerBuilder bpwo(Class<?> beanClass, String properties) {
908      super.bpwo(beanClass, properties);
909      return this;
910   }
911
912   @Override /* GENERATED - BeanContextBuilder */
913   public SerializerBuilder bpwo(String beanClassName, String properties) {
914      super.bpwo(beanClassName, properties);
915      return this;
916   }
917
918   @Override /* GENERATED - BeanContextBuilder */
919   public SerializerBuilder bpx(Map<String,Object> values) {
920      super.bpx(values);
921      return this;
922   }
923
924   @Override /* GENERATED - BeanContextBuilder */
925   public SerializerBuilder bpx(Class<?> beanClass, String properties) {
926      super.bpx(beanClass, properties);
927      return this;
928   }
929
930   @Override /* GENERATED - BeanContextBuilder */
931   public SerializerBuilder bpx(String beanClassName, String properties) {
932      super.bpx(beanClassName, properties);
933      return this;
934   }
935
936   @Override /* GENERATED - BeanContextBuilder */
937   public SerializerBuilder dictionary(Object...values) {
938      super.dictionary(values);
939      return this;
940   }
941
942   @Override /* GENERATED - BeanContextBuilder */
943   public SerializerBuilder dictionaryOn(Class<?> on, java.lang.Class<?>...values) {
944      super.dictionaryOn(on, values);
945      return this;
946   }
947
948   @Override /* GENERATED - BeanContextBuilder */
949   public SerializerBuilder dontIgnorePropertiesWithoutSetters() {
950      super.dontIgnorePropertiesWithoutSetters();
951      return this;
952   }
953
954   @Override /* GENERATED - BeanContextBuilder */
955   public SerializerBuilder dontIgnoreTransientFields() {
956      super.dontIgnoreTransientFields();
957      return this;
958   }
959
960   @Override /* GENERATED - BeanContextBuilder */
961   public SerializerBuilder dontIgnoreUnknownNullBeanProperties() {
962      super.dontIgnoreUnknownNullBeanProperties();
963      return this;
964   }
965
966   @Override /* GENERATED - BeanContextBuilder */
967   public SerializerBuilder dontUseInterfaceProxies() {
968      super.dontUseInterfaceProxies();
969      return this;
970   }
971
972   @Override /* GENERATED - BeanContextBuilder */
973   public <T> SerializerBuilder example(Class<T> pojoClass, T o) {
974      super.example(pojoClass, o);
975      return this;
976   }
977
978   @Override /* GENERATED - BeanContextBuilder */
979   public <T> SerializerBuilder exampleJson(Class<T> pojoClass, String json) {
980      super.exampleJson(pojoClass, json);
981      return this;
982   }
983
984   @Override /* GENERATED - BeanContextBuilder */
985   public SerializerBuilder fluentSetters() {
986      super.fluentSetters();
987      return this;
988   }
989
990   @Override /* GENERATED - BeanContextBuilder */
991   public SerializerBuilder fluentSetters(Class<?> on) {
992      super.fluentSetters(on);
993      return this;
994   }
995
996   @Override /* GENERATED - BeanContextBuilder */
997   public SerializerBuilder ignoreInvocationExceptionsOnGetters() {
998      super.ignoreInvocationExceptionsOnGetters();
999      return this;
1000   }
1001
1002   @Override /* GENERATED - BeanContextBuilder */
1003   public SerializerBuilder ignoreInvocationExceptionsOnSetters() {
1004      super.ignoreInvocationExceptionsOnSetters();
1005      return this;
1006   }
1007
1008   @Override /* GENERATED - BeanContextBuilder */
1009   public SerializerBuilder ignoreUnknownBeanProperties() {
1010      super.ignoreUnknownBeanProperties();
1011      return this;
1012   }
1013
1014   @Override /* GENERATED - BeanContextBuilder */
1015   public SerializerBuilder implClass(Class<?> interfaceClass, Class<?> implClass) {
1016      super.implClass(interfaceClass, implClass);
1017      return this;
1018   }
1019
1020   @Override /* GENERATED - BeanContextBuilder */
1021   public SerializerBuilder implClasses(Map<Class<?>,Class<?>> values) {
1022      super.implClasses(values);
1023      return this;
1024   }
1025
1026   @Override /* GENERATED - BeanContextBuilder */
1027   public SerializerBuilder interfaceClass(Class<?> on, Class<?> value) {
1028      super.interfaceClass(on, value);
1029      return this;
1030   }
1031
1032   @Override /* GENERATED - BeanContextBuilder */
1033   public SerializerBuilder interfaces(java.lang.Class<?>...value) {
1034      super.interfaces(value);
1035      return this;
1036   }
1037
1038   @Override /* GENERATED - BeanContextBuilder */
1039   public SerializerBuilder notBeanClasses(Object...values) {
1040      super.notBeanClasses(values);
1041      return this;
1042   }
1043
1044   @Override /* GENERATED - BeanContextBuilder */
1045   public SerializerBuilder notBeanPackages(Object...values) {
1046      super.notBeanPackages(values);
1047      return this;
1048   }
1049
1050   @Override /* GENERATED - BeanContextBuilder */
1051   public SerializerBuilder propertyNamer(Class<? extends org.apache.juneau.PropertyNamer> value) {
1052      super.propertyNamer(value);
1053      return this;
1054   }
1055
1056   @Override /* GENERATED - BeanContextBuilder */
1057   public SerializerBuilder propertyNamer(Class<?> on, Class<? extends org.apache.juneau.PropertyNamer> value) {
1058      super.propertyNamer(on, value);
1059      return this;
1060   }
1061
1062   @Override /* GENERATED - BeanContextBuilder */
1063   public SerializerBuilder sortProperties() {
1064      super.sortProperties();
1065      return this;
1066   }
1067
1068   @Override /* GENERATED - BeanContextBuilder */
1069   public SerializerBuilder sortProperties(java.lang.Class<?>...on) {
1070      super.sortProperties(on);
1071      return this;
1072   }
1073
1074   @Override /* GENERATED - BeanContextBuilder */
1075   public SerializerBuilder stopClass(Class<?> on, Class<?> value) {
1076      super.stopClass(on, value);
1077      return this;
1078   }
1079
1080   @Override /* GENERATED - BeanContextBuilder */
1081   public SerializerBuilder swaps(Object...values) {
1082      super.swaps(values);
1083      return this;
1084   }
1085
1086   @Override /* GENERATED - BeanContextBuilder */
1087   public SerializerBuilder typeName(Class<?> on, String value) {
1088      super.typeName(on, value);
1089      return this;
1090   }
1091
1092   @Override /* GENERATED - BeanContextBuilder */
1093   public SerializerBuilder typePropertyName(String value) {
1094      super.typePropertyName(value);
1095      return this;
1096   }
1097
1098   @Override /* GENERATED - BeanContextBuilder */
1099   public SerializerBuilder typePropertyName(Class<?> on, String value) {
1100      super.typePropertyName(on, value);
1101      return this;
1102   }
1103
1104   @Override /* GENERATED - BeanContextBuilder */
1105   public SerializerBuilder useEnumNames() {
1106      super.useEnumNames();
1107      return this;
1108   }
1109
1110   @Override /* GENERATED - BeanContextBuilder */
1111   public SerializerBuilder useJavaBeanIntrospector() {
1112      super.useJavaBeanIntrospector();
1113      return this;
1114   }
1115
1116   @Override /* GENERATED - BeanTraverseBuilder */
1117   public SerializerBuilder detectRecursions() {
1118      super.detectRecursions();
1119      return this;
1120   }
1121
1122   @Override /* GENERATED - BeanTraverseBuilder */
1123   public SerializerBuilder ignoreRecursions() {
1124      super.ignoreRecursions();
1125      return this;
1126   }
1127
1128   @Override /* GENERATED - BeanTraverseBuilder */
1129   public SerializerBuilder initialDepth(int value) {
1130      super.initialDepth(value);
1131      return this;
1132   }
1133
1134   @Override /* GENERATED - BeanTraverseBuilder */
1135   public SerializerBuilder maxDepth(int value) {
1136      super.maxDepth(value);
1137      return this;
1138   }
1139
1140   // </FluentSetters>
1141
1142   @Override /* Context */
1143   public Serializer build() {
1144      return null;
1145   }
1146}