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.html;
014
015import static org.apache.juneau.collections.JsonMap.*;
016
017import java.lang.annotation.*;
018import java.lang.reflect.*;
019import java.nio.charset.*;
020import java.util.*;
021
022import org.apache.juneau.*;
023import org.apache.juneau.annotation.*;
024import org.apache.juneau.collections.*;
025import org.apache.juneau.internal.*;
026import org.apache.juneau.json.*;
027import org.apache.juneau.jsonschema.*;
028import org.apache.juneau.utils.*;
029import org.apache.juneau.xml.*;
030
031/**
032 * Serializes POJO metamodels to HTML.
033 *
034 * <h5 class='topic'>Media types</h5>
035 *
036 * Handles <c>Accept</c> types:  <bc>text/html+schema</bc>
037 * <p>
038 * Produces <c>Content-Type</c> types:  <bc>text/html</bc>
039 *
040 * <h5 class='topic'>Description</h5>
041 *
042 * Essentially the same as {@link HtmlSerializer}, except serializes the POJO metamodel instead of the model itself.
043 *
044 * <p>
045 * Produces output that describes the POJO metamodel similar to an XML schema document.
046 *
047 * <p>
048 * The easiest way to create instances of this class is through the {@link HtmlSerializer#getSchemaSerializer()},
049 * which will create a schema serializer with the same settings as the originating serializer.
050 *
051 * <h5 class='section'>Notes:</h5><ul>
052 *    <li class='note'>This class is thread safe and reusable.
053 * </ul>
054 *
055 * <h5 class='section'>See Also:</h5><ul>
056 *    <li class='link'><a class="doclink" href="../../../../index.html#jm.HtmlDetails">HTML Details</a>
057
058 * </ul>
059 */
060public class HtmlSchemaSerializer extends HtmlSerializer {
061
062   //-------------------------------------------------------------------------------------------------------------------
063   // Static
064   //-------------------------------------------------------------------------------------------------------------------
065
066   /** Default serializer, all default settings.*/
067   public static final HtmlSchemaSerializer DEFAULT = new HtmlSchemaSerializer(create());
068
069   /** Default serializer, all default settings.*/
070   public static final HtmlSchemaSerializer DEFAULT_READABLE = new Readable(create());
071
072   /** Default serializer, single quotes, simple mode. */
073   public static final HtmlSchemaSerializer DEFAULT_SIMPLE = new Simple(create());
074
075   /** Default serializer, single quotes, simple mode, with whitespace. */
076   public static final HtmlSchemaSerializer DEFAULT_SIMPLE_READABLE = new SimpleReadable(create());
077
078   /**
079    * Creates a new builder for this object.
080    *
081    * @return A new builder.
082    */
083   public static Builder create() {
084      return new Builder();
085   }
086
087   //-------------------------------------------------------------------------------------------------------------------
088   // Static subclasses
089   //-------------------------------------------------------------------------------------------------------------------
090
091   /** Default serializer, with whitespace. */
092   public static class Readable extends HtmlSchemaSerializer {
093
094      /**
095       * Constructor.
096       *
097       * @param builder The builder for this object.
098       */
099      public Readable(Builder builder) {
100         super(builder.useWhitespace());
101      }
102   }
103
104   /** Default serializer, single quotes, simple mode. */
105   public static class Simple extends HtmlSchemaSerializer {
106
107      /**
108       * Constructor.
109       *
110       * @param builder The builder for this object.
111       */
112      public Simple(Builder builder) {
113         super(builder.quoteChar('\''));
114      }
115   }
116
117   /** Default serializer, single quotes, simple mode, with whitespace. */
118   public static class SimpleReadable extends HtmlSchemaSerializer {
119
120      /**
121       * Constructor.
122       *
123       * @param builder The builder for this object.
124       */
125      public SimpleReadable(Builder builder) {
126         super(builder.quoteChar('\'').useWhitespace());
127      }
128   }
129
130   //-------------------------------------------------------------------------------------------------------------------
131   // Builder
132   //-------------------------------------------------------------------------------------------------------------------
133
134   /**
135    * Builder class.
136    */
137   @FluentSetters
138   public static class Builder extends HtmlSerializer.Builder {
139
140      private static final Cache<HashKey,HtmlSchemaSerializer> CACHE = Cache.of(HashKey.class, HtmlSchemaSerializer.class).build();
141
142      JsonSchemaGenerator.Builder generatorBuilder;
143
144      /**
145       * Constructor, default settings.
146       */
147      protected Builder() {
148         produces("text/html");
149         accept("text/html+schema");
150         generatorBuilder = JsonSchemaGenerator.create().beanContext(beanContext());
151      }
152
153      /**
154       * Copy constructor.
155       *
156       * @param copyFrom The bean to copy from.
157       */
158      protected Builder(HtmlSchemaSerializer copyFrom) {
159         super(copyFrom);
160         generatorBuilder = copyFrom.generator.copy().beanContext(beanContext());
161      }
162
163      /**
164       * Copy constructor.
165       *
166       * @param copyFrom The builder to copy from.
167       */
168      protected Builder(Builder copyFrom) {
169         super(copyFrom);
170         generatorBuilder = copyFrom.generatorBuilder.copy().beanContext(beanContext());
171      }
172
173      @Override /* Context.Builder */
174      public Builder copy() {
175         return new Builder(this);
176      }
177
178      @Override /* Context.Builder */
179      public HtmlSchemaSerializer build() {
180         return cache(CACHE).build(HtmlSchemaSerializer.class);
181      }
182
183      @Override /* Context.Builder */
184      public HashKey hashKey() {
185         return HashKey.of(
186            super.hashKey(),
187            generatorBuilder.hashKey()
188         );
189      }
190
191      //-----------------------------------------------------------------------------------------------------------------
192      // Properties
193      //-----------------------------------------------------------------------------------------------------------------
194
195      /**
196       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Add descriptions.
197       *
198       * <p>
199       * Identifies which categories of types that descriptions should be automatically added to generated schemas.
200       * <p>
201       * The description is the result of calling {@link ClassMeta#getFullName()}.
202       *
203       * <h5 class='section'>See Also:</h5><ul>
204       *    <li class='jm'>{@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#addDescriptionsTo(TypeCategory...)}
205       * </ul>
206       *
207       * @param values
208       *    The values to add to this setting.
209       *    <br>The default is an empty string.
210       * @return This object.
211       */
212      @FluentSetter
213      public Builder addDescriptionsTo(TypeCategory...values) {
214         generatorBuilder.addDescriptionsTo(values);
215         return this;
216      }
217
218      /**
219       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Add examples.
220       *
221       * <p>
222       * Identifies which categories of types that examples should be automatically added to generated schemas.
223       * <p>
224       * The examples come from calling {@link ClassMeta#getExample(BeanSession,JsonParserSession)} which in turn gets examples
225       * from the following:
226       * <ul class='javatree'>
227       *    <li class='ja'>{@link Example}
228       *    <li class='ja'>{@link Marshalled#example() Marshalled(example)}
229       * </ul>
230       *
231       * <h5 class='section'>See Also:</h5><ul>
232       *    <li class='jm'>{@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#addExamplesTo(TypeCategory...)}
233       * </ul>
234       *
235       * @param values
236       *    The values to add to this setting.
237       *    <br>The default is an empty string.
238       * @return This object.
239       */
240      @FluentSetter
241      public Builder addExamplesTo(TypeCategory...values) {
242         generatorBuilder.addExamplesTo(values);
243         return this;
244      }
245
246      /**
247       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Allow nested descriptions.
248       *
249       * <p>
250       * Identifies whether nested descriptions are allowed in schema definitions.
251       *
252       * <h5 class='section'>See Also:</h5><ul>
253       *    <li class='jm'>{@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#allowNestedDescriptions()}
254       * </ul>
255       *
256       * @return This object.
257       */
258      @FluentSetter
259      public Builder allowNestedDescriptions() {
260         generatorBuilder.allowNestedDescriptions();
261         return this;
262      }
263
264      /**
265       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Allow nested examples.
266       *
267       * <p>
268       * Identifies whether nested examples are allowed in schema definitions.
269       *
270       * <h5 class='section'>See Also:</h5><ul>
271       *    <li class='jm'>{@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#allowNestedExamples()}
272       * </ul>
273       *
274       * @return This object.
275       */
276      @FluentSetter
277      public Builder allowNestedExamples() {
278         generatorBuilder.allowNestedExamples();
279         return this;
280      }
281
282      /**
283       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Schema definition mapper.
284       *
285       * <p>
286       * Interface to use for converting Bean classes to definition IDs and URIs.
287       * <p>
288       * Used primarily for defining common definition sections for beans in Swagger JSON.
289       * <p>
290       * This setting is ignored if {@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#useBeanDefs()} is not enabled.
291       *
292       * <h5 class='section'>See Also:</h5><ul>
293       *    <li class='jm'>{@link org.apache.juneau.jsonschema.JsonSchemaGenerator.Builder#beanDefMapper(Class)}
294       * </ul>
295       *
296       * @param value
297       *    The new value for this property.
298       *    <br>The default is {@link org.apache.juneau.jsonschema.BasicBeanDefMapper}.
299       * @return This object.
300       */
301      @FluentSetter
302      public Builder beanDefMapper(Class<? extends BeanDefMapper> value) {
303         generatorBuilder.beanDefMapper(value);
304         return this;
305      }
306
307      /**
308       * <i><l>HtmlSchemaSerializer</l> configuration property:&emsp;</i>  Use bean definitions.
309       *
310       * <p>
311       * When enabled, schemas on beans will be serialized as the following:
312       * <p class='bjson'>
313       *    {
314       *       type: <js>'object'</js>,
315       *       <js>'$ref'</js>: <js>'#/definitions/TypeId'</js>
316       *    }
317       * </p>
318       *
319       * @return This object.
320       */
321      @FluentSetter
322      public Builder useBeanDefs() {
323         generatorBuilder.useBeanDefs();
324         return this;
325      }
326
327      // <FluentSetters>
328
329      @Override /* GENERATED - org.apache.juneau.Context.Builder */
330      public Builder annotations(Annotation...values) {
331         super.annotations(values);
332         return this;
333      }
334
335      @Override /* GENERATED - org.apache.juneau.Context.Builder */
336      public Builder apply(AnnotationWorkList work) {
337         super.apply(work);
338         return this;
339      }
340
341      @Override /* GENERATED - org.apache.juneau.Context.Builder */
342      public Builder applyAnnotations(java.lang.Class<?>...fromClasses) {
343         super.applyAnnotations(fromClasses);
344         return this;
345      }
346
347      @Override /* GENERATED - org.apache.juneau.Context.Builder */
348      public Builder applyAnnotations(Method...fromMethods) {
349         super.applyAnnotations(fromMethods);
350         return this;
351      }
352
353      @Override /* GENERATED - org.apache.juneau.Context.Builder */
354      public Builder cache(Cache<HashKey,? extends org.apache.juneau.Context> value) {
355         super.cache(value);
356         return this;
357      }
358
359      @Override /* GENERATED - org.apache.juneau.Context.Builder */
360      public Builder debug() {
361         super.debug();
362         return this;
363      }
364
365      @Override /* GENERATED - org.apache.juneau.Context.Builder */
366      public Builder debug(boolean value) {
367         super.debug(value);
368         return this;
369      }
370
371      @Override /* GENERATED - org.apache.juneau.Context.Builder */
372      public Builder impl(Context value) {
373         super.impl(value);
374         return this;
375      }
376
377      @Override /* GENERATED - org.apache.juneau.Context.Builder */
378      public Builder type(Class<? extends org.apache.juneau.Context> value) {
379         super.type(value);
380         return this;
381      }
382
383      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
384      public Builder beanClassVisibility(Visibility value) {
385         super.beanClassVisibility(value);
386         return this;
387      }
388
389      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
390      public Builder beanConstructorVisibility(Visibility value) {
391         super.beanConstructorVisibility(value);
392         return this;
393      }
394
395      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
396      public Builder beanContext(BeanContext value) {
397         super.beanContext(value);
398         return this;
399      }
400
401      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
402      public Builder beanContext(BeanContext.Builder value) {
403         super.beanContext(value);
404         return this;
405      }
406
407      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
408      public Builder beanDictionary(java.lang.Class<?>...values) {
409         super.beanDictionary(values);
410         return this;
411      }
412
413      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
414      public Builder beanFieldVisibility(Visibility value) {
415         super.beanFieldVisibility(value);
416         return this;
417      }
418
419      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
420      public Builder beanInterceptor(Class<?> on, Class<? extends org.apache.juneau.swap.BeanInterceptor<?>> value) {
421         super.beanInterceptor(on, value);
422         return this;
423      }
424
425      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
426      public Builder beanMapPutReturnsOldValue() {
427         super.beanMapPutReturnsOldValue();
428         return this;
429      }
430
431      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
432      public Builder beanMethodVisibility(Visibility value) {
433         super.beanMethodVisibility(value);
434         return this;
435      }
436
437      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
438      public Builder beanProperties(Map<String,Object> values) {
439         super.beanProperties(values);
440         return this;
441      }
442
443      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
444      public Builder beanProperties(Class<?> beanClass, String properties) {
445         super.beanProperties(beanClass, properties);
446         return this;
447      }
448
449      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
450      public Builder beanProperties(String beanClassName, String properties) {
451         super.beanProperties(beanClassName, properties);
452         return this;
453      }
454
455      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
456      public Builder beanPropertiesExcludes(Map<String,Object> values) {
457         super.beanPropertiesExcludes(values);
458         return this;
459      }
460
461      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
462      public Builder beanPropertiesExcludes(Class<?> beanClass, String properties) {
463         super.beanPropertiesExcludes(beanClass, properties);
464         return this;
465      }
466
467      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
468      public Builder beanPropertiesExcludes(String beanClassName, String properties) {
469         super.beanPropertiesExcludes(beanClassName, properties);
470         return this;
471      }
472
473      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
474      public Builder beanPropertiesReadOnly(Map<String,Object> values) {
475         super.beanPropertiesReadOnly(values);
476         return this;
477      }
478
479      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
480      public Builder beanPropertiesReadOnly(Class<?> beanClass, String properties) {
481         super.beanPropertiesReadOnly(beanClass, properties);
482         return this;
483      }
484
485      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
486      public Builder beanPropertiesReadOnly(String beanClassName, String properties) {
487         super.beanPropertiesReadOnly(beanClassName, properties);
488         return this;
489      }
490
491      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
492      public Builder beanPropertiesWriteOnly(Map<String,Object> values) {
493         super.beanPropertiesWriteOnly(values);
494         return this;
495      }
496
497      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
498      public Builder beanPropertiesWriteOnly(Class<?> beanClass, String properties) {
499         super.beanPropertiesWriteOnly(beanClass, properties);
500         return this;
501      }
502
503      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
504      public Builder beanPropertiesWriteOnly(String beanClassName, String properties) {
505         super.beanPropertiesWriteOnly(beanClassName, properties);
506         return this;
507      }
508
509      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
510      public Builder beansRequireDefaultConstructor() {
511         super.beansRequireDefaultConstructor();
512         return this;
513      }
514
515      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
516      public Builder beansRequireSerializable() {
517         super.beansRequireSerializable();
518         return this;
519      }
520
521      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
522      public Builder beansRequireSettersForGetters() {
523         super.beansRequireSettersForGetters();
524         return this;
525      }
526
527      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
528      public Builder dictionaryOn(Class<?> on, java.lang.Class<?>...values) {
529         super.dictionaryOn(on, values);
530         return this;
531      }
532
533      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
534      public Builder disableBeansRequireSomeProperties() {
535         super.disableBeansRequireSomeProperties();
536         return this;
537      }
538
539      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
540      public Builder disableIgnoreMissingSetters() {
541         super.disableIgnoreMissingSetters();
542         return this;
543      }
544
545      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
546      public Builder disableIgnoreTransientFields() {
547         super.disableIgnoreTransientFields();
548         return this;
549      }
550
551      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
552      public Builder disableIgnoreUnknownNullBeanProperties() {
553         super.disableIgnoreUnknownNullBeanProperties();
554         return this;
555      }
556
557      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
558      public Builder disableInterfaceProxies() {
559         super.disableInterfaceProxies();
560         return this;
561      }
562
563      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
564      public <T> Builder example(Class<T> pojoClass, T o) {
565         super.example(pojoClass, o);
566         return this;
567      }
568
569      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
570      public <T> Builder example(Class<T> pojoClass, String json) {
571         super.example(pojoClass, json);
572         return this;
573      }
574
575      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
576      public Builder findFluentSetters() {
577         super.findFluentSetters();
578         return this;
579      }
580
581      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
582      public Builder findFluentSetters(Class<?> on) {
583         super.findFluentSetters(on);
584         return this;
585      }
586
587      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
588      public Builder ignoreInvocationExceptionsOnGetters() {
589         super.ignoreInvocationExceptionsOnGetters();
590         return this;
591      }
592
593      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
594      public Builder ignoreInvocationExceptionsOnSetters() {
595         super.ignoreInvocationExceptionsOnSetters();
596         return this;
597      }
598
599      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
600      public Builder ignoreUnknownBeanProperties() {
601         super.ignoreUnknownBeanProperties();
602         return this;
603      }
604
605      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
606      public Builder ignoreUnknownEnumValues() {
607         super.ignoreUnknownEnumValues();
608         return this;
609      }
610
611      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
612      public Builder implClass(Class<?> interfaceClass, Class<?> implClass) {
613         super.implClass(interfaceClass, implClass);
614         return this;
615      }
616
617      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
618      public Builder implClasses(Map<Class<?>,Class<?>> values) {
619         super.implClasses(values);
620         return this;
621      }
622
623      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
624      public Builder interfaceClass(Class<?> on, Class<?> value) {
625         super.interfaceClass(on, value);
626         return this;
627      }
628
629      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
630      public Builder interfaces(java.lang.Class<?>...value) {
631         super.interfaces(value);
632         return this;
633      }
634
635      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
636      public Builder locale(Locale value) {
637         super.locale(value);
638         return this;
639      }
640
641      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
642      public Builder mediaType(MediaType value) {
643         super.mediaType(value);
644         return this;
645      }
646
647      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
648      public Builder notBeanClasses(java.lang.Class<?>...values) {
649         super.notBeanClasses(values);
650         return this;
651      }
652
653      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
654      public Builder notBeanPackages(String...values) {
655         super.notBeanPackages(values);
656         return this;
657      }
658
659      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
660      public Builder propertyNamer(Class<? extends org.apache.juneau.PropertyNamer> value) {
661         super.propertyNamer(value);
662         return this;
663      }
664
665      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
666      public Builder propertyNamer(Class<?> on, Class<? extends org.apache.juneau.PropertyNamer> value) {
667         super.propertyNamer(on, value);
668         return this;
669      }
670
671      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
672      public Builder sortProperties() {
673         super.sortProperties();
674         return this;
675      }
676
677      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
678      public Builder sortProperties(java.lang.Class<?>...on) {
679         super.sortProperties(on);
680         return this;
681      }
682
683      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
684      public Builder stopClass(Class<?> on, Class<?> value) {
685         super.stopClass(on, value);
686         return this;
687      }
688
689      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
690      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction) {
691         super.swap(normalClass, swappedClass, swapFunction);
692         return this;
693      }
694
695      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
696      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction, ThrowingFunction<S,T> unswapFunction) {
697         super.swap(normalClass, swappedClass, swapFunction, unswapFunction);
698         return this;
699      }
700
701      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
702      public Builder swaps(java.lang.Class<?>...values) {
703         super.swaps(values);
704         return this;
705      }
706
707      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
708      public Builder timeZone(TimeZone value) {
709         super.timeZone(value);
710         return this;
711      }
712
713      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
714      public Builder typeName(Class<?> on, String value) {
715         super.typeName(on, value);
716         return this;
717      }
718
719      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
720      public Builder typePropertyName(String value) {
721         super.typePropertyName(value);
722         return this;
723      }
724
725      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
726      public Builder typePropertyName(Class<?> on, String value) {
727         super.typePropertyName(on, value);
728         return this;
729      }
730
731      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
732      public Builder useEnumNames() {
733         super.useEnumNames();
734         return this;
735      }
736
737      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
738      public Builder useJavaBeanIntrospector() {
739         super.useJavaBeanIntrospector();
740         return this;
741      }
742
743      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
744      public Builder detectRecursions() {
745         super.detectRecursions();
746         return this;
747      }
748
749      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
750      public Builder detectRecursions(boolean value) {
751         super.detectRecursions(value);
752         return this;
753      }
754
755      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
756      public Builder ignoreRecursions() {
757         super.ignoreRecursions();
758         return this;
759      }
760
761      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
762      public Builder ignoreRecursions(boolean value) {
763         super.ignoreRecursions(value);
764         return this;
765      }
766
767      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
768      public Builder initialDepth(int value) {
769         super.initialDepth(value);
770         return this;
771      }
772
773      @Override /* GENERATED - org.apache.juneau.BeanTraverseContext.Builder */
774      public Builder maxDepth(int value) {
775         super.maxDepth(value);
776         return this;
777      }
778
779      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
780      public Builder accept(String value) {
781         super.accept(value);
782         return this;
783      }
784
785      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
786      public Builder addBeanTypes() {
787         super.addBeanTypes();
788         return this;
789      }
790
791      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
792      public Builder addBeanTypes(boolean value) {
793         super.addBeanTypes(value);
794         return this;
795      }
796
797      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
798      public Builder addRootType() {
799         super.addRootType();
800         return this;
801      }
802
803      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
804      public Builder addRootType(boolean value) {
805         super.addRootType(value);
806         return this;
807      }
808
809      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
810      public Builder keepNullProperties() {
811         super.keepNullProperties();
812         return this;
813      }
814
815      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
816      public Builder keepNullProperties(boolean value) {
817         super.keepNullProperties(value);
818         return this;
819      }
820
821      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
822      public Builder listener(Class<? extends org.apache.juneau.serializer.SerializerListener> value) {
823         super.listener(value);
824         return this;
825      }
826
827      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
828      public Builder produces(String value) {
829         super.produces(value);
830         return this;
831      }
832
833      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
834      public Builder sortCollections() {
835         super.sortCollections();
836         return this;
837      }
838
839      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
840      public Builder sortCollections(boolean value) {
841         super.sortCollections(value);
842         return this;
843      }
844
845      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
846      public Builder sortMaps() {
847         super.sortMaps();
848         return this;
849      }
850
851      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
852      public Builder sortMaps(boolean value) {
853         super.sortMaps(value);
854         return this;
855      }
856
857      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
858      public Builder trimEmptyCollections() {
859         super.trimEmptyCollections();
860         return this;
861      }
862
863      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
864      public Builder trimEmptyCollections(boolean value) {
865         super.trimEmptyCollections(value);
866         return this;
867      }
868
869      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
870      public Builder trimEmptyMaps() {
871         super.trimEmptyMaps();
872         return this;
873      }
874
875      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
876      public Builder trimEmptyMaps(boolean value) {
877         super.trimEmptyMaps(value);
878         return this;
879      }
880
881      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
882      public Builder trimStrings() {
883         super.trimStrings();
884         return this;
885      }
886
887      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
888      public Builder trimStrings(boolean value) {
889         super.trimStrings(value);
890         return this;
891      }
892
893      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
894      public Builder uriContext(UriContext value) {
895         super.uriContext(value);
896         return this;
897      }
898
899      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
900      public Builder uriRelativity(UriRelativity value) {
901         super.uriRelativity(value);
902         return this;
903      }
904
905      @Override /* GENERATED - org.apache.juneau.serializer.Serializer.Builder */
906      public Builder uriResolution(UriResolution value) {
907         super.uriResolution(value);
908         return this;
909      }
910
911      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
912      public Builder fileCharset(Charset value) {
913         super.fileCharset(value);
914         return this;
915      }
916
917      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
918      public Builder maxIndent(int value) {
919         super.maxIndent(value);
920         return this;
921      }
922
923      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
924      public Builder quoteChar(char value) {
925         super.quoteChar(value);
926         return this;
927      }
928
929      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
930      public Builder quoteCharOverride(char value) {
931         super.quoteCharOverride(value);
932         return this;
933      }
934
935      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
936      public Builder sq() {
937         super.sq();
938         return this;
939      }
940
941      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
942      public Builder streamCharset(Charset value) {
943         super.streamCharset(value);
944         return this;
945      }
946
947      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
948      public Builder useWhitespace() {
949         super.useWhitespace();
950         return this;
951      }
952
953      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
954      public Builder useWhitespace(boolean value) {
955         super.useWhitespace(value);
956         return this;
957      }
958
959      @Override /* GENERATED - org.apache.juneau.serializer.WriterSerializer.Builder */
960      public Builder ws() {
961         super.ws();
962         return this;
963      }
964
965      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
966      public Builder addBeanTypesXml() {
967         super.addBeanTypesXml();
968         return this;
969      }
970
971      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
972      public Builder addBeanTypesXml(boolean value) {
973         super.addBeanTypesXml(value);
974         return this;
975      }
976
977      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
978      public Builder addNamespaceUrisToRoot() {
979         super.addNamespaceUrisToRoot();
980         return this;
981      }
982
983      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
984      public Builder addNamespaceUrisToRoot(boolean value) {
985         super.addNamespaceUrisToRoot(value);
986         return this;
987      }
988
989      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
990      public Builder defaultNamespace(Namespace value) {
991         super.defaultNamespace(value);
992         return this;
993      }
994
995      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
996      public Builder disableAutoDetectNamespaces() {
997         super.disableAutoDetectNamespaces();
998         return this;
999      }
1000
1001      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
1002      public Builder disableAutoDetectNamespaces(boolean value) {
1003         super.disableAutoDetectNamespaces(value);
1004         return this;
1005      }
1006
1007      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
1008      public Builder enableNamespaces() {
1009         super.enableNamespaces();
1010         return this;
1011      }
1012
1013      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
1014      public Builder enableNamespaces(boolean value) {
1015         super.enableNamespaces(value);
1016         return this;
1017      }
1018
1019      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
1020      public Builder namespaces(Namespace...values) {
1021         super.namespaces(values);
1022         return this;
1023      }
1024
1025      @Override /* GENERATED - org.apache.juneau.xml.XmlSerializer.Builder */
1026      public Builder ns() {
1027         super.ns();
1028         return this;
1029      }
1030
1031      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1032      public Builder addBeanTypesHtml() {
1033         super.addBeanTypesHtml();
1034         return this;
1035      }
1036
1037      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1038      public Builder addBeanTypesHtml(boolean value) {
1039         super.addBeanTypesHtml(value);
1040         return this;
1041      }
1042
1043      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1044      public Builder addKeyValueTableHeaders() {
1045         super.addKeyValueTableHeaders();
1046         return this;
1047      }
1048
1049      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1050      public Builder addKeyValueTableHeaders(boolean value) {
1051         super.addKeyValueTableHeaders(value);
1052         return this;
1053      }
1054
1055      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1056      public Builder disableDetectLabelParameters() {
1057         super.disableDetectLabelParameters();
1058         return this;
1059      }
1060
1061      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1062      public Builder disableDetectLabelParameters(boolean value) {
1063         super.disableDetectLabelParameters(value);
1064         return this;
1065      }
1066
1067      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1068      public Builder disableDetectLinksInStrings() {
1069         super.disableDetectLinksInStrings();
1070         return this;
1071      }
1072
1073      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1074      public Builder disableDetectLinksInStrings(boolean value) {
1075         super.disableDetectLinksInStrings(value);
1076         return this;
1077      }
1078
1079      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1080      public Builder labelParameter(String value) {
1081         super.labelParameter(value);
1082         return this;
1083      }
1084
1085      @Override /* GENERATED - org.apache.juneau.html.HtmlSerializer.Builder */
1086      public Builder uriAnchorText(AnchorText value) {
1087         super.uriAnchorText(value);
1088         return this;
1089      }
1090
1091      // </FluentSetters>
1092   }
1093
1094   //-------------------------------------------------------------------------------------------------------------------
1095   // Instance
1096   //-------------------------------------------------------------------------------------------------------------------
1097
1098   final JsonSchemaGenerator generator;
1099
1100   /**
1101    * Constructor.
1102    *
1103    * @param builder The builder for this serializer.
1104    */
1105   public HtmlSchemaSerializer(Builder builder) {
1106      super(builder.detectRecursions().ignoreRecursions());
1107
1108      generator = builder.generatorBuilder.build();
1109   }
1110
1111   @Override /* Context */
1112   public Builder copy() {
1113      return new Builder(this);
1114   }
1115
1116   @Override /* Context */
1117   public HtmlSchemaSerializerSession.Builder createSession() {
1118      return HtmlSchemaSerializerSession.create(this);
1119   }
1120
1121   @Override /* Context */
1122   public HtmlSchemaSerializerSession getSession() {
1123      return createSession().build();
1124   }
1125
1126   JsonSchemaGenerator getGenerator() {
1127      return generator;
1128   }
1129
1130   //-----------------------------------------------------------------------------------------------------------------
1131   // Other methods
1132   //-----------------------------------------------------------------------------------------------------------------
1133
1134   @Override /* Context */
1135   protected JsonMap properties() {
1136      return filteredMap("generator", generator);
1137   }
1138}