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.oapi;
014
015import java.lang.annotation.*;
016import java.lang.reflect.*;
017import java.nio.charset.*;
018import java.util.*;
019import java.util.concurrent.*;
020
021import org.apache.juneau.*;
022import org.apache.juneau.annotation.*;
023import org.apache.juneau.httppart.*;
024import org.apache.juneau.internal.*;
025import org.apache.juneau.uon.*;
026import org.apache.juneau.utils.*;
027
028/**
029 * OpenAPI part parser.
030 *
031 * <h5 class='section'>Notes:</h5><ul>
032 *    <li class='note'>This class is thread safe and reusable.
033 * </ul>
034 *
035 * <h5 class='section'>See Also:</h5><ul>
036 *    <li class='link'><a class="doclink" href="../../../../index.html#jm.OpenApiDetails">OpenAPI Details</a>
037
038 * </ul>
039 */
040public class OpenApiParser extends UonParser implements OpenApiMetaProvider {
041
042   //-------------------------------------------------------------------------------------------------------------------
043   // Static
044   //-------------------------------------------------------------------------------------------------------------------
045
046   /** Reusable instance of {@link OpenApiParser}. */
047   public static final OpenApiParser DEFAULT = new OpenApiParser(create());
048
049   /**
050    * Creates a new builder for this object.
051    *
052    * @return A new builder.
053    */
054   public static Builder create() {
055      return new Builder();
056   }
057
058   //-------------------------------------------------------------------------------------------------------------------
059   // Builder
060   //-------------------------------------------------------------------------------------------------------------------
061
062   /**
063    * Builder class.
064    */
065   @FluentSetters
066   public static class Builder extends UonParser.Builder {
067
068      private static final Cache<HashKey,OpenApiParser> CACHE = Cache.of(HashKey.class, OpenApiParser.class).build();
069
070      HttpPartFormat format;
071      HttpPartCollectionFormat collectionFormat;
072
073      /**
074       * Constructor, default settings.
075       */
076      protected Builder() {
077         super();
078         consumes("text/openapi");
079         format = HttpPartFormat.NO_FORMAT;
080         collectionFormat = HttpPartCollectionFormat.NO_COLLECTION_FORMAT;
081      }
082
083      /**
084       * Copy constructor.
085       *
086       * @param copyFrom The bean to copy from.
087       */
088      protected Builder(OpenApiParser copyFrom) {
089         super(copyFrom);
090         format = copyFrom.format;
091         collectionFormat = copyFrom.collectionFormat;
092      }
093
094      /**
095       * Copy constructor.
096       *
097       * @param copyFrom The builder to copy from.
098       */
099      protected Builder(Builder copyFrom) {
100         super(copyFrom);
101         format = copyFrom.format;
102         collectionFormat = copyFrom.collectionFormat;
103      }
104
105      @Override /* Context.Builder */
106      public Builder copy() {
107         return new Builder(this);
108      }
109
110      @Override /* Context.Builder */
111      public OpenApiParser build() {
112         return cache(CACHE).build(OpenApiParser.class);
113      }
114
115      @Override /* Context.Builder */
116      public HashKey hashKey() {
117         return HashKey.of(
118            super.hashKey(),
119            format,
120            collectionFormat
121         );
122      }
123
124      //-----------------------------------------------------------------------------------------------------------------
125      // Properties
126      //-----------------------------------------------------------------------------------------------------------------
127
128      /**
129       * <i><l>OpenApiCommon</l> configuration property:&emsp;</i>  Default format for HTTP parts.
130       *
131       * <p>
132       * Specifies the format to use for HTTP parts when not otherwise specified via {@link org.apache.juneau.annotation.Schema#format()}.
133       *
134       * <h5 class='section'>Example:</h5>
135       * <p class='bjava'>
136       *    <jc>// Create a plain-text parser.</jc>
137       *    OpenApiParser <jv>parser1</jv> = OpenApiParser
138       *       .<jsm>create</jsm>()
139       *       .build();
140       *
141       *    <jc>// Create a UON parser.</jc>
142       *    OpenApiParser <jv>parser2</jv> = OpenApiParser
143       *       .<jsm>create</jsm>()
144       *       .format(<jsf>UON</jsf>)
145       *       .build();
146       *
147       *    <jc>// Parse a plain-text string.</jc>
148       *    String <jv>value1</jv> = <jv>parser1</jv>.parse(<js>"foo bar"</js>);
149       *
150       *    <jc>// Parse a UON string.</jc>
151       *    String <jv>value2</jv> = <jv>parser1</jv>.parse(<js>"'foo bar'"</js>);
152       * </p>
153       *
154       * <ul class='values javatree'>
155       *    <li class='jc'>{@link org.apache.juneau.httppart.HttpPartFormat}
156       *    <ul>
157       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#UON UON} - UON notation (e.g. <js>"'foo bar'"</js>).
158       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#INT32 INT32} - Signed 32 bits.
159       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#INT64 INT64} - Signed 64 bits.
160       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#FLOAT FLOAT} - 32-bit floating point number.
161       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#DOUBLE DOUBLE} - 64-bit floating point number.
162       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#BYTE BYTE} - BASE-64 encoded characters.
163       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#BINARY BINARY} - Hexadecimal encoded octets (e.g. <js>"00FF"</js>).
164       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#BINARY_SPACED BINARY_SPACED} - Spaced-separated hexadecimal encoded octets (e.g. <js>"00 FF"</js>).
165       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#DATE DATE} - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>.
166       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#DATE_TIME DATE_TIME} - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>.
167       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#PASSWORD PASSWORD} - Used to hint UIs the input needs to be obscured.
168       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartFormat#NO_FORMAT NO_FORMAT} - (default) Not specified.
169       *    </ul>
170       * </ul>
171       *
172       * @param value The new value for this property.
173       * @return This object.
174       */
175      @FluentSetter
176      public Builder format(HttpPartFormat value) {
177         format = value;
178         return this;
179      }
180
181      /**
182       * <i><l>OpenApiCommon</l> configuration property:&emsp;</i>  Default collection format for HTTP parts.
183       *
184       * <p>
185       * Specifies the collection format to use for HTTP parts when not otherwise specified via {@link org.apache.juneau.annotation.Schema#collectionFormat()}.
186       *
187       * <h5 class='section'>Example:</h5>
188       * <p class='bjava'>
189       *    <jc>// Create a parser using CSV for collections.</jc>
190       *    OpenApiParser <jv>parser1</jv> = OpenApiParser
191       *       .<jsm>create</jsm>()
192       *       .collectionFormat(<jsf>CSV</jsf>)
193       *       .build();
194       *
195       *    <jc>// Create a serializer using UON for collections.</jc>
196       *    OpenApiParser <jv>parser2</jv> = OpenApiParser
197       *       .<jsm>create</jsm>()
198       *       .collectionFormat(<jsf>UON</jsf>)
199       *       .build();
200       *
201       *    <jc>// Parse CSV.</jc>
202       *    JsonList <jv>list1</jv> = <jv>parser1</jv>.parse(<js>"foo=bar,baz=qux\,true\,123"</js>, JsonList.<jk>class</jk>)
203       *
204       *    <jc>// Parse UON.</jc>
205       *    JsonList <jv>list2</jv> = <jv>parser2</jv>.parse(<js>"(foo=bar,baz=@(qux,true,123))"</js>, JsonList.<jk>class</jk>)
206       * </p>
207       *
208       * <ul class='values javatree'>
209       *    <li class='jc'>{@link org.apache.juneau.httppart.HttpPartFormat}
210       *    <ul>
211       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#CSV CSV} - (default) Comma-separated values (e.g. <js>"foo,bar"</js>).
212       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#SSV SSV} - Space-separated values (e.g. <js>"foo bar"</js>).
213       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#TSV TSV} - Tab-separated values (e.g. <js>"foo\tbar"</js>).
214       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#PIPES PIPES} - Pipe-separated values (e.g. <js>"foo|bar"</js>).
215       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#MULTI MULTI} - Corresponds to multiple parameter instances instead of multiple values for a single instance (e.g. <js>"foo=bar&amp;foo=baz"</js>).
216       *       <li class='jf'>{@link org.apache.juneau.httppart.HttpPartCollectionFormat#UONC UONC} - UON collection notation (e.g. <js>"@(foo,bar)"</js>).
217       *    </ul>
218       * </ul>
219       *
220       * @param value The new value for this property.
221       * @return This object.
222       */
223      @FluentSetter
224      public Builder collectionFormat(HttpPartCollectionFormat value) {
225         collectionFormat = value;
226         return this;
227      }
228
229      // <FluentSetters>
230
231      @Override /* GENERATED - org.apache.juneau.Context.Builder */
232      public Builder annotations(Annotation...values) {
233         super.annotations(values);
234         return this;
235      }
236
237      @Override /* GENERATED - org.apache.juneau.Context.Builder */
238      public Builder apply(AnnotationWorkList work) {
239         super.apply(work);
240         return this;
241      }
242
243      @Override /* GENERATED - org.apache.juneau.Context.Builder */
244      public Builder applyAnnotations(java.lang.Class<?>...fromClasses) {
245         super.applyAnnotations(fromClasses);
246         return this;
247      }
248
249      @Override /* GENERATED - org.apache.juneau.Context.Builder */
250      public Builder applyAnnotations(Method...fromMethods) {
251         super.applyAnnotations(fromMethods);
252         return this;
253      }
254
255      @Override /* GENERATED - org.apache.juneau.Context.Builder */
256      public Builder cache(Cache<HashKey,? extends org.apache.juneau.Context> value) {
257         super.cache(value);
258         return this;
259      }
260
261      @Override /* GENERATED - org.apache.juneau.Context.Builder */
262      public Builder debug() {
263         super.debug();
264         return this;
265      }
266
267      @Override /* GENERATED - org.apache.juneau.Context.Builder */
268      public Builder debug(boolean value) {
269         super.debug(value);
270         return this;
271      }
272
273      @Override /* GENERATED - org.apache.juneau.Context.Builder */
274      public Builder impl(Context value) {
275         super.impl(value);
276         return this;
277      }
278
279      @Override /* GENERATED - org.apache.juneau.Context.Builder */
280      public Builder type(Class<? extends org.apache.juneau.Context> value) {
281         super.type(value);
282         return this;
283      }
284
285      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
286      public Builder beanClassVisibility(Visibility value) {
287         super.beanClassVisibility(value);
288         return this;
289      }
290
291      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
292      public Builder beanConstructorVisibility(Visibility value) {
293         super.beanConstructorVisibility(value);
294         return this;
295      }
296
297      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
298      public Builder beanContext(BeanContext value) {
299         super.beanContext(value);
300         return this;
301      }
302
303      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
304      public Builder beanContext(BeanContext.Builder value) {
305         super.beanContext(value);
306         return this;
307      }
308
309      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
310      public Builder beanDictionary(java.lang.Class<?>...values) {
311         super.beanDictionary(values);
312         return this;
313      }
314
315      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
316      public Builder beanFieldVisibility(Visibility value) {
317         super.beanFieldVisibility(value);
318         return this;
319      }
320
321      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
322      public Builder beanInterceptor(Class<?> on, Class<? extends org.apache.juneau.swap.BeanInterceptor<?>> value) {
323         super.beanInterceptor(on, value);
324         return this;
325      }
326
327      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
328      public Builder beanMapPutReturnsOldValue() {
329         super.beanMapPutReturnsOldValue();
330         return this;
331      }
332
333      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
334      public Builder beanMethodVisibility(Visibility value) {
335         super.beanMethodVisibility(value);
336         return this;
337      }
338
339      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
340      public Builder beanProperties(Map<String,Object> values) {
341         super.beanProperties(values);
342         return this;
343      }
344
345      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
346      public Builder beanProperties(Class<?> beanClass, String properties) {
347         super.beanProperties(beanClass, properties);
348         return this;
349      }
350
351      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
352      public Builder beanProperties(String beanClassName, String properties) {
353         super.beanProperties(beanClassName, properties);
354         return this;
355      }
356
357      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
358      public Builder beanPropertiesExcludes(Map<String,Object> values) {
359         super.beanPropertiesExcludes(values);
360         return this;
361      }
362
363      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
364      public Builder beanPropertiesExcludes(Class<?> beanClass, String properties) {
365         super.beanPropertiesExcludes(beanClass, properties);
366         return this;
367      }
368
369      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
370      public Builder beanPropertiesExcludes(String beanClassName, String properties) {
371         super.beanPropertiesExcludes(beanClassName, properties);
372         return this;
373      }
374
375      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
376      public Builder beanPropertiesReadOnly(Map<String,Object> values) {
377         super.beanPropertiesReadOnly(values);
378         return this;
379      }
380
381      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
382      public Builder beanPropertiesReadOnly(Class<?> beanClass, String properties) {
383         super.beanPropertiesReadOnly(beanClass, properties);
384         return this;
385      }
386
387      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
388      public Builder beanPropertiesReadOnly(String beanClassName, String properties) {
389         super.beanPropertiesReadOnly(beanClassName, properties);
390         return this;
391      }
392
393      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
394      public Builder beanPropertiesWriteOnly(Map<String,Object> values) {
395         super.beanPropertiesWriteOnly(values);
396         return this;
397      }
398
399      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
400      public Builder beanPropertiesWriteOnly(Class<?> beanClass, String properties) {
401         super.beanPropertiesWriteOnly(beanClass, properties);
402         return this;
403      }
404
405      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
406      public Builder beanPropertiesWriteOnly(String beanClassName, String properties) {
407         super.beanPropertiesWriteOnly(beanClassName, properties);
408         return this;
409      }
410
411      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
412      public Builder beansRequireDefaultConstructor() {
413         super.beansRequireDefaultConstructor();
414         return this;
415      }
416
417      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
418      public Builder beansRequireSerializable() {
419         super.beansRequireSerializable();
420         return this;
421      }
422
423      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
424      public Builder beansRequireSettersForGetters() {
425         super.beansRequireSettersForGetters();
426         return this;
427      }
428
429      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
430      public Builder dictionaryOn(Class<?> on, java.lang.Class<?>...values) {
431         super.dictionaryOn(on, values);
432         return this;
433      }
434
435      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
436      public Builder disableBeansRequireSomeProperties() {
437         super.disableBeansRequireSomeProperties();
438         return this;
439      }
440
441      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
442      public Builder disableIgnoreMissingSetters() {
443         super.disableIgnoreMissingSetters();
444         return this;
445      }
446
447      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
448      public Builder disableIgnoreTransientFields() {
449         super.disableIgnoreTransientFields();
450         return this;
451      }
452
453      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
454      public Builder disableIgnoreUnknownNullBeanProperties() {
455         super.disableIgnoreUnknownNullBeanProperties();
456         return this;
457      }
458
459      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
460      public Builder disableInterfaceProxies() {
461         super.disableInterfaceProxies();
462         return this;
463      }
464
465      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
466      public <T> Builder example(Class<T> pojoClass, T o) {
467         super.example(pojoClass, o);
468         return this;
469      }
470
471      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
472      public <T> Builder example(Class<T> pojoClass, String json) {
473         super.example(pojoClass, json);
474         return this;
475      }
476
477      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
478      public Builder findFluentSetters() {
479         super.findFluentSetters();
480         return this;
481      }
482
483      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
484      public Builder findFluentSetters(Class<?> on) {
485         super.findFluentSetters(on);
486         return this;
487      }
488
489      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
490      public Builder ignoreInvocationExceptionsOnGetters() {
491         super.ignoreInvocationExceptionsOnGetters();
492         return this;
493      }
494
495      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
496      public Builder ignoreInvocationExceptionsOnSetters() {
497         super.ignoreInvocationExceptionsOnSetters();
498         return this;
499      }
500
501      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
502      public Builder ignoreUnknownBeanProperties() {
503         super.ignoreUnknownBeanProperties();
504         return this;
505      }
506
507      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
508      public Builder ignoreUnknownEnumValues() {
509         super.ignoreUnknownEnumValues();
510         return this;
511      }
512
513      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
514      public Builder implClass(Class<?> interfaceClass, Class<?> implClass) {
515         super.implClass(interfaceClass, implClass);
516         return this;
517      }
518
519      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
520      public Builder implClasses(Map<Class<?>,Class<?>> values) {
521         super.implClasses(values);
522         return this;
523      }
524
525      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
526      public Builder interfaceClass(Class<?> on, Class<?> value) {
527         super.interfaceClass(on, value);
528         return this;
529      }
530
531      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
532      public Builder interfaces(java.lang.Class<?>...value) {
533         super.interfaces(value);
534         return this;
535      }
536
537      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
538      public Builder locale(Locale value) {
539         super.locale(value);
540         return this;
541      }
542
543      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
544      public Builder mediaType(MediaType value) {
545         super.mediaType(value);
546         return this;
547      }
548
549      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
550      public Builder notBeanClasses(java.lang.Class<?>...values) {
551         super.notBeanClasses(values);
552         return this;
553      }
554
555      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
556      public Builder notBeanPackages(String...values) {
557         super.notBeanPackages(values);
558         return this;
559      }
560
561      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
562      public Builder propertyNamer(Class<? extends org.apache.juneau.PropertyNamer> value) {
563         super.propertyNamer(value);
564         return this;
565      }
566
567      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
568      public Builder propertyNamer(Class<?> on, Class<? extends org.apache.juneau.PropertyNamer> value) {
569         super.propertyNamer(on, value);
570         return this;
571      }
572
573      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
574      public Builder sortProperties() {
575         super.sortProperties();
576         return this;
577      }
578
579      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
580      public Builder sortProperties(java.lang.Class<?>...on) {
581         super.sortProperties(on);
582         return this;
583      }
584
585      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
586      public Builder stopClass(Class<?> on, Class<?> value) {
587         super.stopClass(on, value);
588         return this;
589      }
590
591      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
592      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction) {
593         super.swap(normalClass, swappedClass, swapFunction);
594         return this;
595      }
596
597      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
598      public <T, S> Builder swap(Class<T> normalClass, Class<S> swappedClass, ThrowingFunction<T,S> swapFunction, ThrowingFunction<S,T> unswapFunction) {
599         super.swap(normalClass, swappedClass, swapFunction, unswapFunction);
600         return this;
601      }
602
603      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
604      public Builder swaps(java.lang.Class<?>...values) {
605         super.swaps(values);
606         return this;
607      }
608
609      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
610      public Builder timeZone(TimeZone value) {
611         super.timeZone(value);
612         return this;
613      }
614
615      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
616      public Builder typeName(Class<?> on, String value) {
617         super.typeName(on, value);
618         return this;
619      }
620
621      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
622      public Builder typePropertyName(String value) {
623         super.typePropertyName(value);
624         return this;
625      }
626
627      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
628      public Builder typePropertyName(Class<?> on, String value) {
629         super.typePropertyName(on, value);
630         return this;
631      }
632
633      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
634      public Builder useEnumNames() {
635         super.useEnumNames();
636         return this;
637      }
638
639      @Override /* GENERATED - org.apache.juneau.BeanContextable.Builder */
640      public Builder useJavaBeanIntrospector() {
641         super.useJavaBeanIntrospector();
642         return this;
643      }
644
645      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
646      public Builder autoCloseStreams() {
647         super.autoCloseStreams();
648         return this;
649      }
650
651      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
652      public Builder autoCloseStreams(boolean value) {
653         super.autoCloseStreams(value);
654         return this;
655      }
656
657      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
658      public Builder consumes(String value) {
659         super.consumes(value);
660         return this;
661      }
662
663      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
664      public Builder debugOutputLines(int value) {
665         super.debugOutputLines(value);
666         return this;
667      }
668
669      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
670      public Builder listener(Class<? extends org.apache.juneau.parser.ParserListener> value) {
671         super.listener(value);
672         return this;
673      }
674
675      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
676      public Builder strict() {
677         super.strict();
678         return this;
679      }
680
681      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
682      public Builder strict(boolean value) {
683         super.strict(value);
684         return this;
685      }
686
687      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
688      public Builder trimStrings() {
689         super.trimStrings();
690         return this;
691      }
692
693      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
694      public Builder trimStrings(boolean value) {
695         super.trimStrings(value);
696         return this;
697      }
698
699      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
700      public Builder unbuffered() {
701         super.unbuffered();
702         return this;
703      }
704
705      @Override /* GENERATED - org.apache.juneau.parser.Parser.Builder */
706      public Builder unbuffered(boolean value) {
707         super.unbuffered(value);
708         return this;
709      }
710
711      @Override /* GENERATED - org.apache.juneau.parser.ReaderParser.Builder */
712      public Builder fileCharset(Charset value) {
713         super.fileCharset(value);
714         return this;
715      }
716
717      @Override /* GENERATED - org.apache.juneau.parser.ReaderParser.Builder */
718      public Builder streamCharset(Charset value) {
719         super.streamCharset(value);
720         return this;
721      }
722
723      @Override /* GENERATED - org.apache.juneau.uon.UonParser.Builder */
724      public Builder decoding() {
725         super.decoding();
726         return this;
727      }
728
729      @Override /* GENERATED - org.apache.juneau.uon.UonParser.Builder */
730      public Builder decoding(boolean value) {
731         super.decoding(value);
732         return this;
733      }
734
735      @Override /* GENERATED - org.apache.juneau.uon.UonParser.Builder */
736      public Builder validateEnd() {
737         super.validateEnd();
738         return this;
739      }
740
741      @Override /* GENERATED - org.apache.juneau.uon.UonParser.Builder */
742      public Builder validateEnd(boolean value) {
743         super.validateEnd(value);
744         return this;
745      }
746
747      // </FluentSetters>
748   }
749
750   //-------------------------------------------------------------------------------------------------------------------
751   // Instance
752   //-------------------------------------------------------------------------------------------------------------------
753
754   final HttpPartFormat format;
755   final HttpPartCollectionFormat collectionFormat;
756
757   private final Map<ClassMeta<?>,OpenApiClassMeta> openApiClassMetas = new ConcurrentHashMap<>();
758   private final Map<BeanPropertyMeta,OpenApiBeanPropertyMeta> openApiBeanPropertyMetas = new ConcurrentHashMap<>();
759
760   /**
761    * Constructor.
762    *
763    * @param builder The builder for this object.
764    */
765   public OpenApiParser(Builder builder) {
766      super(builder);
767      format = builder.format;
768      collectionFormat = builder.collectionFormat;
769   }
770
771   @Override /* Context */
772   public Builder copy() {
773      return new Builder(this);
774   }
775
776   @Override /* Context */
777   public OpenApiParserSession.Builder createSession() {
778      return OpenApiParserSession.create(this);
779   }
780
781   @Override /* Context */
782   public OpenApiParserSession getSession() {
783      return createSession().build();
784   }
785
786   @Override /* HttpPartParser */
787   public OpenApiParserSession getPartSession() {
788      return OpenApiParserSession.create(this).build();
789   }
790
791   //-----------------------------------------------------------------------------------------------------------------
792   // Extended metadata
793   //-----------------------------------------------------------------------------------------------------------------
794
795   @Override /* OpenApiMetaProvider */
796   public OpenApiClassMeta getOpenApiClassMeta(ClassMeta<?> cm) {
797      OpenApiClassMeta m = openApiClassMetas.get(cm);
798      if (m == null) {
799         m = new OpenApiClassMeta(cm, this);
800         openApiClassMetas.put(cm, m);
801      }
802      return m;
803   }
804
805   @Override /* OpenApiMetaProvider */
806   public OpenApiBeanPropertyMeta getOpenApiBeanPropertyMeta(BeanPropertyMeta bpm) {
807      if (bpm == null)
808         return OpenApiBeanPropertyMeta.DEFAULT;
809      OpenApiBeanPropertyMeta m = openApiBeanPropertyMetas.get(bpm);
810      if (m == null) {
811         m = new OpenApiBeanPropertyMeta(bpm.getDelegateFor(), this);
812         openApiBeanPropertyMetas.put(bpm, m);
813      }
814      return m;
815   }
816
817   //-----------------------------------------------------------------------------------------------------------------
818   // Properties
819   //-----------------------------------------------------------------------------------------------------------------
820
821   /**
822    * Returns the default format to use when not otherwise specified via {@link Schema#format()}
823    *
824    * @return The default format to use when not otherwise specified via {@link Schema#format()}
825    */
826   protected final HttpPartFormat getFormat() {
827      return format;
828   }
829
830   /**
831    * Returns the default collection format to use when not otherwise specified via {@link Schema#collectionFormat()}
832    *
833    * @return The default collection format to use when not otherwise specified via {@link Schema#collectionFormat()}
834    */
835   protected final HttpPartCollectionFormat getCollectionFormat() {
836      return collectionFormat;
837   }
838}