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