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.dto.swagger;
014
015import static org.apache.juneau.internal.BeanPropertyUtils.*;
016import java.util.*;
017
018import org.apache.juneau.annotation.*;
019
020/**
021 * The Schema Object allows the definition of input and output data types.
022 * 
023 * <p>
024 * These types can be objects, but also primitives and arrays.
025 * This object is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it.
026 * On top of this subset, there are extensions provided by this specification to allow for more complete documentation.
027 * 
028 * <p>
029 * Further information about the properties can be found in JSON Schema Core and JSON Schema Validation.
030 * Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here.
031 * 
032 * <h5 class='section'>Example:</h5>
033 * <p class='bcode'>
034 *    <jc>// Construct using SwaggerBuilder.</jc>
035 *    SchemaInfo x = <jsm>schemaInfo</jsm>()
036 *       .type("string")
037 *       .title("foo")
038 * 
039 *    <jc>// Serialize using JsonSerializer.</jc>
040 *    String json = JsonSerializer.<jsf>DEFAULT</jsf>.toString(x);
041 * 
042 *    <jc>// Or just use toString() which does the same as above.</jc>
043 *    String json = x.toString();
044 * </p>
045 * <p class='bcode'>
046 *    <jc>// Output</jc>
047 *    {
048 *       <js>"type"</js>: <js>"string"</js>,
049 *       <js>"title"</js>: <js>"foo"</js>
050 *    }
051 * </p>
052 * 
053 * <h5 class='section'>See Also:</h5>
054 * <ul class='doctree'>
055 *    <li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview &gt; juneau-dto &gt; Swagger</a>
056 * </ul>
057 */
058@Bean(properties="format,title,description,default,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,maxProperties,minProperties,required,enum,type,items,allOf,properties,additionalProperties,discriminator,readOnly,xml,externalDocs,example,*")
059public class SchemaInfo extends SwaggerElement {
060
061   private String 
062      format,
063      title,
064      description,
065      pattern,
066      type,
067      discriminator;
068   private Number 
069      multipleOf,
070      maximum,
071      minimum;
072   private Integer 
073      maxLength,
074      minLength,
075      maxItems,
076      minItems,
077      maxProperties,
078      minProperties;
079   private Boolean 
080      exclusiveMaximum,
081      exclusiveMinimum,
082      uniqueItems,
083      required,
084      readOnly;
085   private Object 
086      _default,
087      example;
088   private Items items;
089   private Xml xml;
090   private ExternalDocumentation externalDocs;
091   private List<Object> 
092      _enum,
093      allOf;
094   private Map<String,Map<String,Object>> properties;
095   private Map<String,Object> additionalProperties;
096
097   /**
098    * Bean property getter:  <property>format</property>.
099    * 
100    * <h5 class='section'>See Also:</h5>
101    * <ul>
102    *    <li class='extlink'><a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a>
103    * </ul>
104    * 
105    * @return The property value, or <jk>null</jk> if it is not set.
106    */
107   public String getFormat() {
108      return format;
109   }
110
111   /**
112    * Bean property setter:  <property>format</property>.
113    * 
114    * <h5 class='section'>See Also:</h5>
115    * <ul>
116    *    <li class='extlink'><a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a>
117    * </ul>
118    * 
119    * @param value 
120    *    The new value for this property.
121    *    <br>Can be <jk>null</jk> to unset the property.
122    * @return This object (for method chaining).
123    */
124   public SchemaInfo setFormat(String value) {
125      format = value;
126      return this;
127   }
128
129   /**
130    * Same as {@link #setFormat(String)}.
131    * 
132    * @param value
133    *    The new value for this property.
134    *    <br>Non-String values will be converted to String using <code>toString()</code>.
135    *    <br>Can be <jk>null</jk> to unset the property.
136    * @return This object (for method chaining).
137    */
138   public SchemaInfo format(Object value) {
139      return setFormat(toStringVal(value));
140   }
141
142   /**
143    * Bean property getter:  <property>title</property>.
144    * 
145    * @return The property value, or <jk>null</jk> if it is not set.
146    */
147   public String getTitle() {
148      return title;
149   }
150
151   /**
152    * Bean property setter:  <property>title</property>.
153    * 
154    * @param value 
155    *    The new value for this property.
156    *    <br>Can be <jk>null</jk> to unset the property.
157    * @return This object (for method chaining).
158    */
159   public SchemaInfo setTitle(String value) {
160      title = value;
161      return this;
162   }
163
164   /**
165    * Same as {@link #setTitle(String)}.
166    * 
167    * @param value
168    *    The new value for this property.
169    *    <br>Non-String values will be converted to String using <code>toString()</code>.
170    *    <br>Can be <jk>null</jk> to unset the property.
171    * @return This object (for method chaining).
172    */
173   public SchemaInfo title(Object value) {
174      return setTitle(toStringVal(value));
175   }
176
177   /**
178    * Bean property getter:  <property>description</property>.
179    * 
180    * @return The property value, or <jk>null</jk> if it is not set.
181    */
182   public String getDescription() {
183      return description;
184   }
185
186   /**
187    * Bean property setter:  <property>description</property>.
188    * 
189    * @param value 
190    *    The new value for this property.
191    *    <br><a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> can be used for rich text representation.
192    *    <br>Can be <jk>null</jk> to unset the property.
193    * @return This object (for method chaining).
194    */
195   public SchemaInfo setDescription(String value) {
196      description = value;
197      return this;
198   }
199
200   /**
201    * Same as {@link #setDescription(String)}.
202    * 
203    * @param value
204    *    The new value for this property.
205    *    <br>Non-String values will be converted to String using <code>toString()</code>.
206    *    <br>Can be <jk>null</jk> to unset the property.
207    * @return This object (for method chaining).
208    */
209   public SchemaInfo description(Object value) {
210      return setDescription(toStringVal(value));
211   }
212
213   /**
214    * Bean property getter:  <property>default</property>.
215    * 
216    * <p>
217    * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.
218    * 
219    * @return The property value, or <jk>null</jk> if it is not set.
220    */
221   public Object getDefault() {
222      return _default;
223   }
224
225   /**
226    * Bean property setter:  <property>default</property>.
227    * 
228    * <p>
229    * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.
230    * 
231    * @param value 
232    *    The new value for this property.
233    *    <br>Can be <jk>null</jk> to unset the property.
234    * @return This object (for method chaining).
235    */
236   public SchemaInfo setDefault(Object value) {
237      _default = value;
238      return this;
239   }
240
241   /**
242    * Same as {@link #setDefault(Object)}.
243    * 
244    * @param value The new value for this property.
245    * @return This object (for method chaining).
246    */
247   public SchemaInfo _default(Object value) {
248      return setDefault(value);
249   }
250
251   /**
252    * Bean property getter:  <property>multipleOf</property>.
253    * 
254    * @return The property value, or <jk>null</jk> if it is not set.
255    */
256   public Number getMultipleOf() {
257      return multipleOf;
258   }
259
260   /**
261    * Bean property setter:  <property>multipleOf</property>.
262    * 
263    * @param value 
264    *    The new value for this property.
265    *    <br>Can be <jk>null</jk> to unset the property.
266    * @return This object (for method chaining).
267    */
268   public SchemaInfo setMultipleOf(Number value) {
269      multipleOf = value;
270      return this;
271   }
272
273   /**
274    * Same as {@link #setMultipleOf(Number)}.
275    * 
276    * @param value
277    *    The new value for this property.
278    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
279    *    <br>Can be <jk>null</jk> to unset the property.
280    * @return This object (for method chaining).
281    */
282   public SchemaInfo multipleOf(Object value) {
283      return setMultipleOf(toNumber(value));
284   }
285
286   /**
287    * Bean property getter:  <property>maximum</property>.
288    * 
289    * @return The property value, or <jk>null</jk> if it is not set.
290    */
291   public Number getMaximum() {
292      return maximum;
293   }
294
295   /**
296    * Bean property setter:  <property>maximum</property>.
297    * 
298    * @param value 
299    *    The new value for this property.
300    *    <br>Can be <jk>null</jk> to unset the property.
301    * @return This object (for method chaining).
302    */
303   public SchemaInfo setMaximum(Number value) {
304      maximum = value;
305      return this;
306   }
307
308   /**
309    * Same as {@link #setMaximum(Number)}.
310    * 
311    * @param value
312    *    The new value for this property.
313    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
314    *    <br>Can be <jk>null</jk> to unset the property.
315    * @return This object (for method chaining).
316    */
317   public SchemaInfo maximum(Object value) {
318      return setMaximum(toNumber(value));
319   }
320
321   /**
322    * Bean property getter:  <property>exclusiveMaximum</property>.
323    * 
324    * @return The property value, or <jk>null</jk> if it is not set.
325    */
326   public Boolean getExclusiveMaximum() {
327      return exclusiveMaximum;
328   }
329
330   /**
331    * Bean property setter:  <property>exclusiveMaximum</property>.
332    * 
333    * @param value 
334    *    The new value for this property.
335    *    <br>Can be <jk>null</jk> to unset the property.
336    * @return This object (for method chaining).
337    */
338   public SchemaInfo setExclusiveMaximum(Boolean value) {
339      exclusiveMaximum = value;
340      return this;
341   }
342
343   /**
344    * Same as {@link #setExclusiveMaximum(Boolean)}.
345    * 
346    * @param value
347    *    The new value for this property.
348    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
349    *    <br>Can be <jk>null</jk> to unset the property.
350    * @return This object (for method chaining).
351    */
352   public SchemaInfo exclusiveMaximum(Object value) {
353      return setExclusiveMaximum(toBoolean(value));
354   }
355
356   /**
357    * Bean property getter:  <property>minimum</property>.
358    * 
359    * @return The property value, or <jk>null</jk> if it is not set.
360    */
361   public Number getMinimum() {
362      return minimum;
363   }
364
365   /**
366    * Bean property setter:  <property>minimum</property>.
367    * 
368    * @param value 
369    *    The new value for this property.
370    *    <br>Can be <jk>null</jk> to unset the property.
371    * @return This object (for method chaining).
372    */
373   public SchemaInfo setMinimum(Number value) {
374      minimum = value;
375      return this;
376   }
377
378   /**
379    * Same as {@link #setMinimum(Number)}.
380    * 
381    * @param value
382    *    The new value for this property.
383    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
384    *    <br>Can be <jk>null</jk> to unset the property.
385    * @return This object (for method chaining).
386    */
387   public SchemaInfo minimum(Object value) {
388      return setMinimum(toNumber(value));
389   }
390
391   /**
392    * Bean property getter:  <property>exclusiveMinimum</property>.
393    * 
394    * @return The property value, or <jk>null</jk> if it is not set.
395    */
396   public Boolean getExclusiveMinimum() {
397      return exclusiveMinimum;
398   }
399
400   /**
401    * Bean property setter:  <property>exclusiveMinimum</property>.
402    * 
403    * @param value 
404    *    The new value for this property.
405    *    <br>Can be <jk>null</jk> to unset the property.
406    * @return This object (for method chaining).
407    */
408   public SchemaInfo setExclusiveMinimum(Boolean value) {
409      exclusiveMinimum = value;
410      return this;
411   }
412
413   /**
414    * Same as {@link #setExclusiveMinimum(Boolean)}.
415    * 
416    * @param value
417    *    The new value for this property.
418    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
419    *    <br>Can be <jk>null</jk> to unset the property.
420    * @return This object (for method chaining).
421    */
422   public SchemaInfo exclusiveMinimum(Object value) {
423      return setExclusiveMinimum(toBoolean(value));
424   }
425
426   /**
427    * Bean property getter:  <property>maxLength</property>.
428    * 
429    * @return The property value, or <jk>null</jk> if it is not set.
430    */
431   public Integer getMaxLength() {
432      return maxLength;
433   }
434
435   /**
436    * Bean property setter:  <property>maxLength</property>.
437    * 
438    * @param value 
439    *    The new value for this property.
440    *    <br>Can be <jk>null</jk> to unset the property.
441    * @return This object (for method chaining).
442    */
443   public SchemaInfo setMaxLength(Integer value) {
444      maxLength = value;
445      return this;
446   }
447
448   /**
449    * Same as {@link #setMaxLength(Integer)}.
450    * 
451    * @param value
452    *    The new value for this property.
453    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
454    *    <br>Can be <jk>null</jk> to unset the property.
455    * @return This object (for method chaining).
456    */
457   public SchemaInfo maxLength(Object value) {
458      return setMaxLength(toInteger(value));
459   }
460
461   /**
462    * Bean property getter:  <property>minLength</property>.
463    * 
464    * @return The property value, or <jk>null</jk> if it is not set.
465    */
466   public Integer getMinLength() {
467      return minLength;
468   }
469
470   /**
471    * Bean property setter:  <property>minLength</property>.
472    * 
473    * @param value 
474    *    The new value for this property.
475    *    <br>Can be <jk>null</jk> to unset the property.
476    * @return This object (for method chaining).
477    */
478   public SchemaInfo setMinLength(Integer value) {
479      minLength = value;
480      return this;
481   }
482
483   /**
484    * Same as {@link #setMinLength(Integer)}.
485    * 
486    * @param value
487    *    The new value for this property.
488    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
489    *    <br>Can be <jk>null</jk> to unset the property.
490    * @return This object (for method chaining).
491    */
492   public SchemaInfo minLength(Object value) {
493      return setMinLength(toInteger(value));
494   }
495
496   /**
497    * Bean property getter:  <property>pattern</property>.
498    * 
499    * @return The property value, or <jk>null</jk> if it is not set.
500    */
501   public String getPattern() {
502      return pattern;
503   }
504
505   /**
506    * Bean property setter:  <property>pattern</property>.
507    * 
508    * @param value 
509    *    The new value for this property.
510    *    <br>Can be <jk>null</jk> to unset the property.
511    * @return This object (for method chaining).
512    */
513   public SchemaInfo setPattern(String value) {
514      pattern = value;
515      return this;
516   }
517
518   /**
519    * Same as {@link #setPattern(String)}.
520    * 
521    * @param value
522    *    The new value for this property.
523    *    <br>Non-String values will be converted to String using <code>toString()</code>.
524    *    <br>Can be <jk>null</jk> to unset the property.
525    * @return This object (for method chaining).
526    */
527   public SchemaInfo pattern(Object value) {
528      return setPattern(toStringVal(value));
529   }
530
531   /**
532    * Bean property getter:  <property>maxItems</property>.
533    * 
534    * @return The property value, or <jk>null</jk> if it is not set.
535    */
536   public Integer getMaxItems() {
537      return maxItems;
538   }
539
540   /**
541    * Bean property setter:  <property>maxItems</property>.
542    * 
543    * @param value 
544    *    The new value for this property.
545    *    <br>Can be <jk>null</jk> to unset the property.
546    * @return This object (for method chaining).
547    */
548   public SchemaInfo setMaxItems(Integer value) {
549      maxItems = value;
550      return this;
551   }
552
553   /**
554    * Same as {@link #setMaxItems(Integer)}.
555    * 
556    * @param value
557    *    The new value for this property.
558    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
559    *    <br>Can be <jk>null</jk> to unset the property.
560    * @return This object (for method chaining).
561    */
562   public SchemaInfo maxItems(Object value) {
563      return setMaxItems(toInteger(value));
564   }
565
566   /**
567    * Bean property getter:  <property>minItems</property>.
568    * 
569    * @return The property value, or <jk>null</jk> if it is not set.
570    */
571   public Integer getMinItems() {
572      return minItems;
573   }
574
575   /**
576    * Bean property setter:  <property>minItems</property>.
577    * 
578    * @param value 
579    *    The new value for this property.
580    *    <br>Can be <jk>null</jk> to unset the property.
581    * @return This object (for method chaining).
582    */
583   public SchemaInfo setMinItems(Integer value) {
584      minItems = value;
585      return this;
586   }
587
588   /**
589    * Same as {@link #setMinItems(Integer)}.
590    * 
591    * @param value
592    *    The new value for this property.
593    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
594    *    <br>Can be <jk>null</jk> to unset the property.
595    * @return This object (for method chaining).
596    */
597   public SchemaInfo minItems(Object value) {
598      return setMinItems(toInteger(value));
599   }
600
601   /**
602    * Bean property getter:  <property>uniqueItems</property>.
603    * 
604    * @return The property value, or <jk>null</jk> if it is not set.
605    */
606   public Boolean getUniqueItems() {
607      return uniqueItems;
608   }
609   /**
610    * Bean property setter:  <property>uniqueItems</property>.
611    * 
612    * @param value 
613    *    The new value for this property.
614    *    <br>Can be <jk>null</jk> to unset the property.
615    * @return This object (for method chaining).
616    */
617   public SchemaInfo setUniqueItems(Boolean value) {
618      uniqueItems = value;
619      return this;
620   }
621
622   /**
623    * Same as {@link #setUniqueItems(Boolean)}.
624    * 
625    * @param value
626    *    The new value for this property.
627    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
628    *    <br>Can be <jk>null</jk> to unset the property.
629    * @return This object (for method chaining).
630    */
631   public SchemaInfo uniqueItems(Object value) {
632      return setUniqueItems(toBoolean(value));
633   }
634
635   /**
636    * Bean property getter:  <property>maxProperties</property>.
637    * 
638    * @return The property value, or <jk>null</jk> if it is not set.
639    */
640   public Integer getMaxProperties() {
641      return maxProperties;
642   }
643
644   /**
645    * Bean property setter:  <property>maxProperties</property>.
646    * 
647    * @param value 
648    *    The new value for this property.
649    *    <br>Can be <jk>null</jk> to unset the property.
650    * @return This object (for method chaining).
651    */
652   public SchemaInfo setMaxProperties(Integer value) {
653      maxProperties = value;
654      return this;
655   }
656
657   /**
658    * Same as {@link #setMaxProperties(Integer)}.
659    * 
660    * @param value
661    *    The new value for this property.
662    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
663    *    <br>Can be <jk>null</jk> to unset the property.
664    * @return This object (for method chaining).
665    */
666   public SchemaInfo maxProperties(Object value) {
667      return setMaxProperties(toInteger(value));
668   }
669
670   /**
671    * Bean property getter:  <property>minProperties</property>.
672    * 
673    * @return The property value, or <jk>null</jk> if it is not set.
674    */
675   public Integer getMinProperties() {
676      return minProperties;
677   }
678
679   /**
680    * Bean property setter:  <property>minProperties</property>.
681    * 
682    * @param value 
683    *    The new value for this property.
684    *    <br>Can be <jk>null</jk> to unset the property.
685    * @return This object (for method chaining).
686    */
687   public SchemaInfo setMinProperties(Integer value) {
688      minProperties = value;
689      return this;
690   }
691
692   /**
693    * Same as {@link #setMinProperties(Integer)}.
694    * 
695    * @param value
696    *    The new value for this property.
697    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
698    *    <br>Can be <jk>null</jk> to unset the property.
699    * @return This object (for method chaining).
700    */
701   public SchemaInfo minProperties(Object value) {
702      return setMinProperties(toInteger(value));
703   }
704
705   /**
706    * Bean property getter:  <property>required</property>.
707    * 
708    * @return The property value, or <jk>null</jk> if it is not set.
709    */
710   public Boolean getRequired() {
711      return required;
712   }
713
714   /**
715    * Bean property setter:  <property>required</property>.
716    * 
717    * @param value 
718    *    The new value for this property.
719    *    <br>Can be <jk>null</jk> to unset the property.
720    * @return This object (for method chaining).
721    */
722   public SchemaInfo setRequired(Boolean value) {
723      required = value;
724      return this;
725   }
726
727   /**
728    * Same as {@link #setRequired(Boolean)}.
729    * 
730    * @param value
731    *    The new value for this property.
732    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
733    *    <br>Can be <jk>null</jk> to unset the property.
734    * @return This object (for method chaining).
735    */
736   public SchemaInfo required(Object value) {
737      return setRequired(toBoolean(value));
738   }
739
740   /**
741    * Bean property getter:  <property>enum</property>.
742    * 
743    * @return The property value, or <jk>null</jk> if it is not set.
744    */
745   public List<Object> getEnum() {
746      return _enum;
747   }
748
749   /**
750    * Bean property setter:  <property>enum</property>.
751    * 
752    * <h5 class='section'>See Also:</h5>
753    * <ul>
754    *    <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76">http://json-schema.org/latest/json-schema-validation.html#anchor76</a>
755    * </ul>
756    * 
757    * @param value 
758    *    The new value for this property.
759    *    <br>Can be <jk>null</jk> to unset the property.
760    * @return This object (for method chaining).
761    */
762   public SchemaInfo setEnum(Collection<Object> value) {
763      _enum = newList(value);
764      return this;
765   }
766
767   /**
768    * Adds one or more values to the <property>enum</property> property.
769    * 
770    * @param value
771    *    The values to add to this property.
772    *    <br>Ignored if <jk>null</jk>.
773    * @return This object (for method chaining).
774    */
775   public SchemaInfo addEnum(Collection<Object> value) {
776      _enum = addToList(_enum, value);
777      return this;
778   }
779   
780   /**
781    * Adds one or more values to the <property>enum</property> property.
782    * 
783    * @param values
784    *    The values to add to this property.
785    *    <br>Valid types:
786    *    <ul>
787    *       <li><code>Object</code>
788    *       <li><code>Collection&lt;Object&gt;</code>
789    *       <li><code>String</code> - JSON array representation of <code>Collection&lt;Object&gt;</code>
790    *          <h5 class='figure'>Example:</h5>
791    *          <p class='bcode'>
792    *    _enum(<js>"['foo','bar']"</js>);
793    *          </p>
794    *       <li><code>String</code> - Individual values
795    *          <h5 class='figure'>Example:</h5>
796    *          <p class='bcode'>
797    *    _enum(<js>"foo"</js>, <js>"bar"</js>);
798    *          </p>
799    *    </ul>
800    *    <br>Ignored if <jk>null</jk>.
801    * @return This object (for method chaining).
802    */
803   public SchemaInfo _enum(Object...values) {
804      _enum = addToList(_enum, values, Object.class);
805      return this;
806   }
807
808   /**
809    * Bean property getter:  <property>type</property>.
810    * 
811    * @return The property value, or <jk>null</jk> if it is not set.
812    */
813   public String getType() {
814      return type;
815   }
816
817   /**
818    * Bean property setter:  <property>type</property>.
819    * 
820    * @param value 
821    *    The new value for this property.
822    *    <br>Can be <jk>null</jk> to unset the property.
823    * @return This object (for method chaining).
824    */
825   public SchemaInfo setType(String value) {
826      type = value;
827      return this;
828   }
829
830   /**
831    * Same as {@link #setType(String)}.
832    * 
833    * @param value
834    *    The new value for this property.
835    *    <br>Non-String values will be converted to String using <code>toString()</code>.
836    *    <br>Can be <jk>null</jk> to unset the property.
837    * @return This object (for method chaining).
838    */
839   public SchemaInfo type(Object value) {
840      return setType(toStringVal(value));
841   }
842
843   /**
844    * Bean property getter:  <property>items</property>.
845    * 
846    * @return The property value, or <jk>null</jk> if it is not set.
847    */
848   public Items getItems() {
849      return items;
850   }
851
852   /**
853    * Bean property setter:  <property>items</property>.
854    * 
855    * @param value 
856    *    The new value for this property.
857    *    <br>Can be <jk>null</jk> to unset the property.
858    * @return This object (for method chaining).
859    */
860   public SchemaInfo setItems(Items value) {
861      items = value;
862      return this;
863   }
864
865   /**
866    * Same as {@link #setItems(Items)}.
867    * 
868    * @param value 
869    *    The new value for this property.
870    *    <br>Valid types:
871    *    <ul>
872    *       <li>{@link Items}
873    *       <li><code>String</code> - JSON object representation of {@link Items}
874    *          <h5 class='figure'>Example:</h5>
875    *          <p class='bcode'>
876    *    items(<js>"{type:'type',format:'format',...}"</js>);
877    *          </p>
878    *    </ul>
879    *    <br>Can be <jk>null</jk> to unset the property.
880    * @return This object (for method chaining).
881    */
882   public SchemaInfo items(Object value) {
883      return setItems(toType(value, Items.class));
884   }
885
886   /**
887    * Bean property getter:  <property>allOf</property>.
888    * 
889    * @return The property value, or <jk>null</jk> if it is not set.
890    */
891   public List<Object> getAllOf() {
892      return allOf;
893   }
894
895   /**
896    * Bean property setter:  <property>allOf</property>.
897    * 
898    * @param value 
899    *    The new value for this property.
900    *    <br>Can be <jk>null</jk> to unset the property.
901    * @return This object (for method chaining).
902    */
903   public SchemaInfo setAllOf(Collection<Object> value) {
904      allOf = newList(value);
905      return this;
906   }
907
908   /**
909    * Adds one or more values to the <property>allOf</property> property.
910    * 
911    * @param values
912    *    The values to add to this property.
913    *    <br>Ignored if <jk>null</jk>.
914    * @return This object (for method chaining).
915    */
916   public SchemaInfo addAllOf(Collection<Object> values) {
917      allOf = addToList(allOf, values);
918      return this;
919   }
920
921   /**
922    * Adds one or more values to the <property>allOf</property> property.
923    * 
924    * @param values
925    *    The values to add to this property.
926    *    <br>Valid types:
927    *    <ul>
928    *       <li><code>Object</code>
929    *       <li><code>Collection&lt;Object&gt;</code>
930    *       <li><code>String</code> - JSON array representation of <code>Collection&lt;Object&gt;</code>
931    *          <h5 class='figure'>Example:</h5>
932    *          <p class='bcode'>
933    *    allOf(<js>"['foo','bar']"</js>);
934    *          </p>
935    *       <li><code>String</code> - Individual values
936    *          <h5 class='figure'>Example:</h5>
937    *          <p class='bcode'>
938    *    allOf(<js>"foo"</js>, <js>"bar"</js>);
939    *          </p>
940    *    </ul>
941    *    <br>Ignored if <jk>null</jk>.
942    * @return This object (for method chaining).
943    */
944   public SchemaInfo allOf(Object...values) {
945      allOf = addToList(allOf, values, Object.class);
946      return this;
947   }
948
949   /**
950    * Bean property getter:  <property>properties</property>.
951    * 
952    * @return The property value, or <jk>null</jk> if it is not set.
953    */
954   public Map<String,Map<String,Object>> getProperties() {
955      return properties;
956   }
957
958   /**
959    * Bean property setter:  <property>properties</property>.
960    * 
961    * @param value 
962    *    The new value for this property.
963    *    <br>Can be <jk>null</jk> to unset the property.
964    * @return This object (for method chaining).
965    */
966   public SchemaInfo setProperties(Map<String,Map<String,Object>> value) {
967      properties = newMap(value);
968      return this;
969   }
970
971   /**
972    * Adds one or more values to the <property>properties</property> property.
973    * 
974    * @param values
975    *    The values to add to this property.
976    *    <br>Ignored if <jk>null</jk>.
977    * @return This object (for method chaining).
978    */
979   public SchemaInfo addProperties(Map<String,Map<String,Object>> values) {
980      properties = addToMap(properties, values);
981      return this;
982   }
983
984   /**
985    * Adds one or more values to the <property>properties</property> property.
986    * 
987    * @param values
988    *    The values to add to this property.
989    *    <br>Valid types:
990    *    <ul>
991    *       <li><code>Map&lt;String,Map&lt;String,Object&gt;&gt;</code>
992    *       <li><code>String</code> - JSON object representation of <code>Map&lt;String,Map&lt;String,Object&gt;&gt;</code>
993    *          <h5 class='figure'>Example:</h5>
994    *          <p class='bcode'>
995    *    properties(<js>"{name:{foo:'bar'}}"</js>);
996    *          </p>
997    *    </ul>
998    *    <br>Ignored if <jk>null</jk>.
999    * @return This object (for method chaining).
1000    */
1001   @SuppressWarnings({ "unchecked", "rawtypes" })
1002   public SchemaInfo properties(Object...values) {
1003      properties = addToMap((Map)properties, values, String.class, Map.class, String.class, Object.class);
1004      return this;
1005   }
1006
1007   /**
1008    * Bean property getter:  <property>additionalProperties</property>.
1009    * 
1010    * @return The property value, or <jk>null</jk> if it is not set.
1011    */
1012   public Map<String,Object> getAdditionalProperties() {
1013      return additionalProperties;
1014   }
1015
1016   /**
1017    * Bean property setter:  <property>additionalProperties</property>.
1018    * 
1019    * @param value 
1020    *    The new value for this property.
1021    *    <br>Can be <jk>null</jk> to unset the property.
1022    * @return This object (for method chaining).
1023    */
1024   public SchemaInfo setAdditionalProperties(Map<String,Object> value) {
1025      additionalProperties = newMap(value);
1026      return this;
1027   }
1028
1029   /**
1030    * Adds one or more values to the <property>additionalProperties</property> property.
1031    * 
1032    * @param values
1033    *    The values to add to this property.
1034    *    <br>Ignored if <jk>null</jk>.
1035    * @return This object (for method chaining).
1036    */
1037   public SchemaInfo addAdditionalProperties(Map<String,Object> values) {
1038      additionalProperties = addToMap(additionalProperties, values);
1039      return this;
1040   }
1041
1042   /**
1043    * Adds a single value to the <property>additionalProperties</property> property.
1044    * 
1045    * @param name The extra property name.
1046    * @param value The extra property value.
1047    * @return This object (for method chaining).
1048    */
1049   public SchemaInfo additionalProperty(String name, Object value) {
1050      additionalProperties = addToMap(additionalProperties, name, value);
1051      return this;
1052   }
1053
1054   /**
1055    * Adds one or more values to the <property>properties</property> property.
1056    * 
1057    * @param values
1058    *    The values to add to this property.
1059    *    <br>Valid types:
1060    *    <ul>
1061    *       <li><code>Map&lt;String,Object&gt;</code>
1062    *       <li><code>String</code> - JSON object representation of <code>Map&lt;String,Object&gt;</code>
1063    *          <h5 class='figure'>Example:</h5>
1064    *          <p class='bcode'>
1065    *    extraProperties(<js>"{name:'value'}"</js>);
1066    *          </p>
1067    *    </ul>
1068    *    <br>Ignored if <jk>null</jk>.
1069    * @return This object (for method chaining).
1070    */
1071   public SchemaInfo additionalProperties(Object...values) {
1072      additionalProperties = addToMap(additionalProperties, values, String.class, Object.class);
1073      return this;
1074   }
1075
1076   /**
1077    * Bean property getter:  <property>discriminator</property>.
1078    * 
1079    * @return The property value, or <jk>null</jk> if it is not set.
1080    */
1081   public String getDiscriminator() {
1082      return discriminator;
1083   }
1084
1085   /**
1086    * Bean property setter:  <property>discriminator</property>.
1087    * 
1088    * @param value 
1089    *    The new value for this property.
1090    *    <br>Can be <jk>null</jk> to unset the property.
1091    * @return This object (for method chaining).
1092    */
1093   public SchemaInfo setDiscriminator(String value) {
1094      discriminator = value;
1095      return this;
1096   }
1097
1098   /**
1099    * Same as {@link #setDiscriminator(String)}.
1100    * 
1101    * @param value
1102    *    The new value for this property.
1103    *    <br>Non-String values will be converted to String using <code>toString()</code>.
1104    *    <br>Can be <jk>null</jk> to unset the property.
1105    * @return This object (for method chaining).
1106    */
1107   public SchemaInfo discriminator(Object value) {
1108      return setDiscriminator(toStringVal(value));
1109   }
1110
1111   /**
1112    * Bean property getter:  <property>readOnly</property>.
1113    * 
1114    * @return The property value, or <jk>null</jk> if it is not set.
1115    */
1116   public Boolean getReadOnly() {
1117      return readOnly;
1118   }
1119
1120   /**
1121    * Bean property setter:  <property>readOnly</property>.
1122    * 
1123    * @param value 
1124    *    The new value for this property.
1125    *    <br>Can be <jk>null</jk> to unset the property.
1126    * @return This object (for method chaining).
1127    */
1128   public SchemaInfo setReadOnly(Boolean value) {
1129      readOnly = value;
1130      return this;
1131   }
1132
1133   /**
1134    * Same as {@link #setReadOnly(Boolean)}.
1135    * 
1136    * @param value
1137    *    The new value for this property.
1138    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
1139    *    <br>Can be <jk>null</jk> to unset the property.
1140    * @return This object (for method chaining).
1141    */
1142   public SchemaInfo readOnly(Object value) {
1143      return setReadOnly(toBoolean(value));
1144   }
1145
1146   /**
1147    * Bean property getter:  <property>xml</property>.
1148    * 
1149    * @return The property value, or <jk>null</jk> if it is not set.
1150    */
1151   public Xml getXml() {
1152      return xml;
1153   }
1154
1155   /**
1156    * Bean property setter:  <property>xml</property>.
1157    * 
1158    * @param value 
1159    *    The new value for this property.
1160    *    <br>Can be <jk>null</jk> to unset the property.
1161    * @return This object (for method chaining).
1162    */
1163   public SchemaInfo setXml(Xml value) {
1164      xml = value;
1165      return this;
1166   }
1167
1168   /**
1169    * Same as {@link #setXml(Xml)}.
1170    * 
1171    * @param value 
1172    *    The new value for this property.
1173    *    <br>Valid types:
1174    *    <ul>
1175    *       <li>{@link Xml}
1176    *       <li><code>String</code> - JSON object representation of {@link Xml}
1177    *          <h5 class='figure'>Example:</h5>
1178    *          <p class='bcode'>
1179    *    xml(<js>"{name:'name',namespace:'namespace',...}"</js>);
1180    *          </p>
1181    *    </ul>
1182    *    <br>Can be <jk>null</jk> to unset the property.
1183    * @return This object (for method chaining).
1184    */
1185   public SchemaInfo xml(Object value) {
1186      return setXml(toType(value, Xml.class));
1187   }
1188
1189   /**
1190    * Bean property getter:  <property>externalDocs</property>.
1191    * 
1192    * @return The property value, or <jk>null</jk> if it is not set.
1193    */
1194   public ExternalDocumentation getExternalDocs() {
1195      return externalDocs;
1196   }
1197
1198   /**
1199    * Bean property setter:  <property>externalDocs</property>.
1200    * 
1201    * @param value 
1202    *    The new value for this property.
1203    *    <br>Can be <jk>null</jk> to unset the property.
1204    * @return This object (for method chaining).
1205    */
1206   public SchemaInfo setExternalDocs(ExternalDocumentation value) {
1207      externalDocs = value;
1208      return this;
1209   }
1210
1211   /**
1212    * Same as {@link #setExternalDocs(ExternalDocumentation)}.
1213    * 
1214    * @param value 
1215    *    The new value for this property.
1216    *    <br>Valid types:
1217    *    <ul>
1218    *       <li>{@link ExternalDocumentation}
1219    *       <li><code>String</code> - JSON object representation of {@link ExternalDocumentation}
1220    *          <h5 class='figure'>Example:</h5>
1221    *          <p class='bcode'>
1222    *    externalDocs(<js>"{description:'description',url:'url'}"</js>);
1223    *          </p>
1224    *    </ul>
1225    *    <br>Can be <jk>null</jk> to unset the property.
1226    * @return This object (for method chaining).
1227    */
1228   public SchemaInfo externalDocs(Object value) {
1229      return setExternalDocs(toType(value, ExternalDocumentation.class));
1230   }
1231
1232   /**
1233    * Bean property getter:  <property>example</property>.
1234    * 
1235    * @return The property value, or <jk>null</jk> if it is not set.
1236    */
1237   public Object getExample() {
1238      return example;
1239   }
1240
1241   /**
1242    * Bean property setter:  <property>example</property>.
1243    * 
1244    * @param value 
1245    *    The new value for this property.
1246    *    <br>Can be <jk>null</jk> to unset the property.
1247    * @return This object (for method chaining).
1248    */
1249   public SchemaInfo setExample(Object value) {
1250      example = value;
1251      return this;
1252   }
1253
1254   /**
1255    * Same as {@link #setExample(Object)}.
1256    * 
1257    * @param value 
1258    *    The new value for this property.
1259    *    <br>Can be <jk>null</jk> to unset the property.
1260    * @return This object (for method chaining).
1261    */
1262   public SchemaInfo example(Object value) {
1263      return setExample(value);
1264   }
1265
1266   @Override /* SwaggerElement */
1267   public <T> T get(String property, Class<T> type) {
1268      if (property == null)
1269         return null;
1270      switch (property) {
1271         case "format": return toType(getFormat(), type);
1272         case "title": return toType(getTitle(), type);
1273         case "description": return toType(getDescription(), type);
1274         case "default": return toType(getDefault(), type);
1275         case "multipleOf": return toType(getMultipleOf(), type);
1276         case "maximum": return toType(getMaximum(), type);
1277         case "exclusiveMaximum": return toType(getExclusiveMaximum(), type);
1278         case "minimum": return toType(getMinimum(), type);
1279         case "exclusiveMinimum": return toType(getExclusiveMinimum(), type);
1280         case "maxLength": return toType(getMaxLength(), type);
1281         case "minLength": return toType(getMinLength(), type);
1282         case "pattern": return toType(getPattern(), type);
1283         case "maxItems": return toType(getMaxItems(), type);
1284         case "minItems": return toType(getMinItems(), type);
1285         case "uniqueItems": return toType(getUniqueItems(), type);
1286         case "maxProperties": return toType(getMaxProperties(), type);
1287         case "minProperties": return toType(getMinProperties(), type);
1288         case "required": return toType(getRequired(), type);
1289         case "enum": return toType(getEnum(), type);
1290         case "type": return toType(getType(), type);
1291         case "items": return toType(getItems(), type);
1292         case "allOf": return toType(getAllOf(), type);
1293         case "properties": return toType(getProperties(), type);
1294         case "additionalProperties": return toType(getAdditionalProperties(), type);
1295         case "discriminator": return toType(getDiscriminator(), type);
1296         case "readOnly": return toType(getReadOnly(), type);
1297         case "xml": return toType(getXml(), type);
1298         case "externalDocs": return toType(getExternalDocs(), type);
1299         case "example": return toType(getExample(), type);
1300         default: return super.get(property, type);
1301      }
1302   }
1303
1304   @Override /* SwaggerElement */
1305   public SchemaInfo set(String property, Object value) {
1306      if (property == null)
1307         return this;
1308      switch (property) {
1309         case "format": return format(value);
1310         case "title": return title(value);
1311         case "description": return description(value);
1312         case "default": return _default(value);
1313         case "multipleOf": return multipleOf(value);
1314         case "maximum": return maximum(value);
1315         case "exclusiveMaximum": return exclusiveMaximum(value);
1316         case "minimum": return minimum(value);
1317         case "exclusiveMinimum": return exclusiveMinimum(value);
1318         case "maxLength": return maxLength(value);
1319         case "minLength": return minLength(value);
1320         case "pattern": return pattern(value);
1321         case "maxItems": return maxItems(value);
1322         case "minItems": return minItems(value);
1323         case "uniqueItems": return uniqueItems(value);
1324         case "maxProperties": return maxProperties(value);
1325         case "minProperties": return minProperties(value);
1326         case "required": return required(value);
1327         case "enum": return setEnum(null)._enum(value);
1328         case "type": return type(value);
1329         case "items": return items(value);
1330         case "allOf": return setAllOf(null).allOf(value);
1331         case "properties": return setProperties(null).properties(value);
1332         case "additionalProperties": return setAdditionalProperties(null).additionalProperties(value);
1333         case "discriminator": return discriminator(value);
1334         case "readOnly": return readOnly(value);
1335         case "xml": return xml(value);
1336         case "externalDocs": return externalDocs(value);
1337         case "example": return example(value);
1338         default: 
1339            super.set(property, value);
1340            return this;
1341      }
1342   }
1343}