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