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.httppart;
014
015import static org.apache.juneau.internal.StringUtils.*;
016import java.lang.annotation.*;
017import java.lang.reflect.*;
018import java.util.*;
019import java.util.regex.*;
020
021import org.apache.juneau.*;
022import org.apache.juneau.collections.*;
023import org.apache.juneau.http.annotation.*;
024import org.apache.juneau.jsonschema.annotation.Schema;
025import org.apache.juneau.jsonschema.annotation.Items;
026import org.apache.juneau.jsonschema.annotation.SubItems;
027import org.apache.juneau.reflect.*;
028
029/**
030 * The builder class for creating {@link HttpPartSchema} objects.
031 *
032 */
033public class HttpPartSchemaBuilder {
034   String name, _default;
035   Set<Integer> codes;
036   Set<String> _enum;
037   Boolean allowEmptyValue, exclusiveMaximum, exclusiveMinimum, required, uniqueItems, skipIfEmpty;
038   HttpPartCollectionFormat collectionFormat = HttpPartCollectionFormat.NO_COLLECTION_FORMAT;
039   HttpPartDataType type = HttpPartDataType.NO_TYPE;
040   HttpPartFormat format = HttpPartFormat.NO_FORMAT;
041   Pattern pattern;
042   Number maximum, minimum, multipleOf;
043   Long maxLength, minLength, maxItems, minItems, maxProperties, minProperties;
044   Map<String,Object> properties;
045   Object items, additionalProperties;
046   boolean noValidate;
047   Class<? extends HttpPartParser> parser;
048   Class<? extends HttpPartSerializer> serializer;
049
050   /**
051    * Instantiates a new {@link HttpPartSchema} object based on the configuration of this builder.
052    *
053    * <p>
054    * This method can be called multiple times to produce new schema objects.
055    *
056    * @return
057    *    A new {@link HttpPartSchema} object.
058    *    <br>Never <jk>null</jk>.
059    */
060   public HttpPartSchema build() {
061      return new HttpPartSchema(this);
062   }
063
064   HttpPartSchemaBuilder apply(Class<? extends Annotation> c, ParamInfo mpi) {
065      apply(c, mpi.getParameterType().innerType());
066      for (Annotation a : mpi.getDeclaredAnnotations())
067         if (c.isInstance(a))
068            apply(a);
069      return this;
070   }
071
072   HttpPartSchemaBuilder apply(Class<? extends Annotation> c, Method m) {
073      apply(c, m.getGenericReturnType());
074      Annotation a = m.getAnnotation(c);
075      if (a != null)
076         return apply(a);
077      return this;
078   }
079
080   HttpPartSchemaBuilder apply(Class<? extends Annotation> c, java.lang.reflect.Type t) {
081      if (t instanceof Class<?>) {
082         ClassInfo ci = ClassInfo.of((Class<?>)t);
083         for (Annotation a : ci.getAnnotations(c))
084            apply(a);
085      } else if (Value.isType(t)) {
086         apply(c, Value.getParameterType(t));
087      }
088      return this;
089   }
090
091   /**
092    * Apply the specified annotation to this schema.
093    *
094    * @param a The annotation to apply.
095    * @return This object (for method chaining).
096    */
097   public HttpPartSchemaBuilder apply(Annotation a) {
098      if (a instanceof Body)
099         apply((Body)a);
100      else if (a instanceof Header)
101         apply((Header)a);
102      else if (a instanceof FormData)
103         apply((FormData)a);
104      else if (a instanceof Query)
105         apply((Query)a);
106      else if (a instanceof Path)
107         apply((Path)a);
108      else if (a instanceof Response)
109         apply((Response)a);
110      else if (a instanceof ResponseHeader)
111         apply((ResponseHeader)a);
112      else if (a instanceof HasQuery)
113         apply((HasQuery)a);
114      else if (a instanceof HasFormData)
115         apply((HasFormData)a);
116      else if (a instanceof Schema)
117         apply((Schema)a);
118      else
119         throw new RuntimeException("HttpPartSchemaBuilder.apply(@"+a.getClass().getSimpleName()+") not defined");
120      return this;
121   }
122
123   HttpPartSchemaBuilder apply(Body a) {
124      required(a.required() || a.r());
125      allowEmptyValue(! (a.required() || a.r()));
126      apply(a.schema());
127      return this;
128   }
129
130   HttpPartSchemaBuilder apply(Header a) {
131      name(firstNonEmpty(a.name(), a.n(), a.value()));
132      required(a.required() || a.r());
133      type(firstNonEmpty(a.type(), a.t()));
134      format(firstNonEmpty(a.format(), a.f()));
135      allowEmptyValue(a.allowEmptyValue() || a.aev());
136      items(a.items());
137      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
138      _default(joinnlOrNull(a._default(), a.df()));
139      maximum(toNumber(a.maximum(), a.max()));
140      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
141      minimum(toNumber(a.minimum(), a.min()));
142      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
143      maxLength(firstNmo(a.maxLength(), a.maxl()));
144      minLength(firstNmo(a.minLength(), a.minl()));
145      pattern(firstNonEmpty(a.pattern(), a.p()));
146      maxItems(firstNmo(a.maxItems(), a.maxi()));
147      minItems(firstNmo(a.minItems(), a.mini()));
148      uniqueItems(a.uniqueItems() || a.ui());
149      _enum(toSet(a._enum(), a.e()));
150      multipleOf(toNumber(a.multipleOf(), a.mo()));
151      skipIfEmpty(a.skipIfEmpty() || a.sie());
152      parser(a.parser());
153      serializer(a.serializer());
154      return this;
155   }
156
157   HttpPartSchemaBuilder apply(ResponseHeader a) {
158      name(firstNonEmpty(a.name(), a.n(), a.value()));
159      type(firstNonEmpty(a.type(), a.t()));
160      format(firstNonEmpty(a.format(), a.f()));
161      items(a.items());
162      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
163      _default(joinnlOrNull(a._default(), a.df()));
164      maximum(toNumber(a.maximum(), a.max()));
165      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
166      minimum(toNumber(a.minimum(), a.min()));
167      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
168      maxLength(firstNmo(a.maxLength(), a.maxl()));
169      minLength(firstNmo(a.minLength(), a.minl()));
170      pattern(firstNonEmpty(a.pattern(), a.p()));
171      maxItems(firstNmo(a.maxItems(), a.maxi()));
172      minItems(firstNmo(a.minItems(), a.mini()));
173      uniqueItems(a.uniqueItems() || a.ui());
174      _enum(toSet(a._enum(), a.e()));
175      multipleOf(toNumber(a.multipleOf(), a.mo()));
176      allowEmptyValue(false);
177      serializer(a.serializer());
178      return this;
179   }
180
181   HttpPartSchemaBuilder apply(FormData a) {
182      name(firstNonEmpty(a.name(), a.n(), a.value()));
183      required(a.required() || a.r());
184      type(firstNonEmpty(a.type(), a.t()));
185      format(firstNonEmpty(a.format(), a.f()));
186      allowEmptyValue(a.allowEmptyValue() || a.aev());
187      items(a.items());
188      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
189      _default(joinnlOrNull(a._default(), a.df()));
190      maximum(toNumber(a.maximum(), a.max()));
191      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
192      minimum(toNumber(a.minimum(), a.min()));
193      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
194      maxLength(firstNmo(a.maxLength(), a.maxl()));
195      minLength(firstNmo(a.minLength(), a.minl()));
196      pattern(firstNonEmpty(a.pattern(), a.p()));
197      maxItems(firstNmo(a.maxItems(), a.maxi()));
198      minItems(firstNmo(a.minItems(), a.mini()));
199      uniqueItems(a.uniqueItems() || a.ui());
200      _enum(toSet(a._enum(), a.e()));
201      multipleOf(toNumber(a.multipleOf(), a.mo()));
202      skipIfEmpty(a.skipIfEmpty() || a.sie());
203      parser(a.parser());
204      serializer(a.serializer());
205      return this;
206   }
207
208   HttpPartSchemaBuilder apply(Query a) {
209      name(firstNonEmpty(a.name(), a.n(), a.value()));
210      required(a.required() || a.r());
211      type(firstNonEmpty(a.type(), a.t()));
212      format(firstNonEmpty(a.format(), a.f()));
213      allowEmptyValue(a.allowEmptyValue() || a.aev());
214      items(a.items());
215      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
216      _default(joinnlOrNull(a._default(), a.df()));
217      maximum(toNumber(a.maximum(), a.max()));
218      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
219      minimum(toNumber(a.minimum(), a.min()));
220      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
221      maxLength(firstNmo(a.maxLength(), a.maxl()));
222      minLength(firstNmo(a.minLength(), a.minl()));
223      pattern(firstNonEmpty(a.pattern(), a.p()));
224      maxItems(firstNmo(a.maxItems(), a.maxi()));
225      minItems(firstNmo(a.minItems(), a.mini()));
226      uniqueItems(a.uniqueItems() || a.ui());
227      _enum(toSet(a._enum(), a.e()));
228      multipleOf(toNumber(a.multipleOf(), a.mo()));
229      skipIfEmpty(a.skipIfEmpty() || a.sie());
230      parser(a.parser());
231      serializer(a.serializer());
232      return this;
233   }
234
235   HttpPartSchemaBuilder apply(Path a) {
236      name(firstNonEmpty(a.name(), a.n(), a.value()));
237      type(firstNonEmpty(a.type(), a.t()));
238      format(firstNonEmpty(a.format(), a.f()));
239      items(a.items());
240      allowEmptyValue(a.allowEmptyValue() || a.aev());
241      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
242      maximum(toNumber(a.maximum(), a.max()));
243      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
244      minimum(toNumber(a.minimum(), a.min()));
245      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
246      maxLength(firstNmo(a.maxLength(), a.maxl()));
247      minLength(firstNmo(a.minLength(), a.minl()));
248      pattern(firstNonEmpty(a.pattern(), a.p()));
249      maxItems(firstNmo(a.maxItems(), a.maxi()));
250      minItems(firstNmo(a.minItems(), a.mini()));
251      uniqueItems(a.uniqueItems() || a.ui());
252      _enum(toSet(a._enum(), a.e()));
253      multipleOf(toNumber(a.multipleOf(), a.mo()));
254      parser(a.parser());
255      serializer(a.serializer());
256
257      // Path remainder always allows empty value.
258      if (startsWith(name, '/')) {
259         allowEmptyValue();
260         required(false);
261      } else {
262         required(a.required() && a.r());
263      }
264
265      return this;
266   }
267
268   HttpPartSchemaBuilder apply(Response a) {
269      codes(a.value());
270      codes(a.code());
271      required(false);
272      allowEmptyValue(true);
273      serializer(a.serializer());
274      parser(a.parser());
275      apply(a.schema());
276      return this;
277   }
278
279   HttpPartSchemaBuilder apply(Items a) {
280      type(firstNonEmpty(a.type(), a.t()));
281      format(firstNonEmpty(a.format(), a.f()));
282      items(a.items());
283      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
284      _default(joinnlOrNull(a._default(), a.df()));
285      maximum(toNumber(a.maximum(), a.max()));
286      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
287      minimum(toNumber(a.minimum(), a.min()));
288      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
289      maxLength(firstNmo(a.maxLength(), a.maxl()));
290      minLength(firstNmo(a.minLength(), a.minl()));
291      pattern(firstNonEmpty(a.pattern(), a.p()));
292      maxItems(firstNmo(a.maxItems(), a.maxi()));
293      minItems(firstNmo(a.minItems(), a.mini()));
294      uniqueItems(a.uniqueItems() || a.ui());
295      _enum(toSet(a._enum(), a.e()));
296      multipleOf(toNumber(a.multipleOf(), a.mo()));
297      return this;
298   }
299
300   HttpPartSchemaBuilder apply(SubItems a) {
301      type(firstNonEmpty(a.type(), a.t()));
302      format(firstNonEmpty(a.format(), a.f()));
303      items(HttpPartSchema.toOMap(a.items()));
304      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
305      _default(joinnlOrNull(a._default(), a.df()));
306      maximum(toNumber(a.maximum(), a.max()));
307      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
308      minimum(toNumber(a.minimum(), a.min()));
309      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
310      maxLength(firstNmo(a.maxLength(), a.maxl()));
311      minLength(firstNmo(a.minLength(), a.minl()));
312      pattern(firstNonEmpty(a.pattern(), a.p()));
313      maxItems(firstNmo(a.maxItems(), a.maxi()));
314      minItems(firstNmo(a.minItems(), a.mini()));
315      uniqueItems(a.uniqueItems() || a.ui());
316      _enum(toSet(a._enum(), a.e()));
317      multipleOf(toNumber(a.multipleOf(), a.mo()));
318      return this;
319   }
320
321   HttpPartSchemaBuilder apply(Schema a) {
322      type(firstNonEmpty(a.type(), a.t()));
323      format(firstNonEmpty(a.format(), a.f()));
324      items(a.items());
325      collectionFormat(firstNonEmpty(a.collectionFormat(), a.cf()));
326      _default(joinnlOrNull(a._default(), a.df()));
327      maximum(toNumber(a.maximum(), a.max()));
328      exclusiveMaximum(a.exclusiveMaximum() || a.emax());
329      minimum(toNumber(a.minimum(), a.min()));
330      exclusiveMinimum(a.exclusiveMinimum() || a.emin());
331      maxLength(firstNmo(a.maxLength(), a.maxl()));
332      minLength(firstNmo(a.minLength(), a.minl()));
333      pattern(firstNonEmpty(a.pattern(), a.p()));
334      maxItems(firstNmo(a.maxItems(), a.maxi()));
335      minItems(firstNmo(a.minItems(), a.mini()));
336      uniqueItems(a.uniqueItems() || a.ui());
337      _enum(toSet(a._enum(), a.e()));
338      multipleOf(toNumber(a.multipleOf(), a.mo()));
339      maxProperties(firstNmo(a.maxProperties(), a.maxp()));
340      minProperties(firstNmo(a.minProperties(), a.minp()));
341      properties(HttpPartSchema.toOMap(a.properties()));
342      additionalProperties(HttpPartSchema.toOMap(a.additionalProperties()));
343      return this;
344   }
345
346   HttpPartSchemaBuilder apply(HasQuery a) {
347      name(firstNonEmpty(a.name(), a.n(), a.value()));
348      return this;
349   }
350
351   HttpPartSchemaBuilder apply(HasFormData a) {
352      name(firstNonEmpty(a.name(), a.n(), a.value()));
353      return this;
354   }
355
356   HttpPartSchemaBuilder apply(OMap m) {
357      if (m != null && ! m.isEmpty()) {
358         _default(m.getString("default"));
359         _enum(HttpPartSchema.toSet(m.getString("enum")));
360         allowEmptyValue(m.getBoolean("allowEmptyValue"));
361         exclusiveMaximum(m.getBoolean("exclusiveMaximum"));
362         exclusiveMinimum(m.getBoolean("exclusiveMinimum"));
363         required(m.getBoolean("required"));
364         uniqueItems(m.getBoolean("uniqueItems"));
365         collectionFormat(m.getString("collectionFormat"));
366         type(m.getString("type"));
367         format(m.getString("format"));
368         pattern(m.getString("pattern"));
369         maximum(m.get("maximum", Number.class));
370         minimum(m.get("minimum", Number.class));
371         multipleOf(m.get("multipleOf", Number.class));
372         maxItems(m.get("maxItems", Long.class));
373         maxLength(m.get("maxLength", Long.class));
374         maxProperties(m.get("maxProperties", Long.class));
375         minItems(m.get("minItems", Long.class));
376         minLength(m.get("minLength", Long.class));
377         minProperties(m.get("minProperties", Long.class));
378
379         items(m.getMap("items"));
380         properties(m.getMap("properties"));
381         additionalProperties(m.getMap("additionalProperties"));
382
383         apply(m.getMap("schema", null));
384      }
385      return this;
386   }
387
388   /**
389    * <mk>name</mk> field.
390    *
391    * <p>
392    * Applicable to the following Swagger schema objects:
393    * <ul>
394    *    <li>{@doc ExtSwaggerParameterObject Parameter}
395    *    <li>{@doc ExtSwaggerHeaderObject Header}
396    * </ul>
397    *
398    * @param value
399    *    The new value for this property.
400    * @return This object (for method chaining).
401    */
402   public HttpPartSchemaBuilder name(String value) {
403      if (isNotEmpty(value))
404         name = value;
405      return this;
406   }
407
408   /**
409    * Synonym for {@link #name(String)}.
410    *
411    * @param value
412    *    The new value for this property.
413    * @return This object (for method chaining).
414    */
415   public HttpPartSchemaBuilder n(String value) {
416      return name(value);
417   }
418
419   /**
420    * <mk>httpStatusCode</mk> key.
421    *
422    * <p>
423    * Applicable to the following Swagger schema objects:
424    * <ul>
425    *    <li>{@doc ExtSwaggerResponsesObject Responses}
426    * </ul>
427    *
428    * @param value
429    *    The new value for this property.
430    *    <br>Ignored if <jk>null</jk> or an empty array.
431    * @return This object (for method chaining).
432    */
433   public HttpPartSchemaBuilder codes(int[] value) {
434      if (value != null && value.length != 0)
435         for (int v : value)
436            code(v);
437      return this;
438   }
439
440   /**
441    * <mk>httpStatusCode</mk> key.
442    *
443    * <p>
444    * Applicable to the following Swagger schema objects:
445    * <ul>
446    *    <li>{@doc ExtSwaggerResponsesObject Responses}
447    * </ul>
448    *
449    * @param value
450    *    The new value for this property.
451    *    <br>Ignored if value is <c>0</c>.
452    * @return This object (for method chaining).
453    */
454   public HttpPartSchemaBuilder code(int value) {
455      if (value != 0) {
456         if (codes == null)
457            codes = new TreeSet<>();
458         codes.add(value);
459      }
460      return this;
461   }
462
463   /**
464    * <mk>required</mk> field.
465    *
466    * <p>
467    * Determines whether the parameter is mandatory.
468    *
469    * <p>
470    * Applicable to the following Swagger schema objects:
471    * <ul>
472    *    <li>{@doc ExtSwaggerParameterObject Parameter}
473    *    <li>{@doc ExtSwaggerSchemaObject Schema}
474    * </ul>
475    *
476    * @param value
477    *    The new value for this property.
478    *    <br>Ignored if value is <jk>null</jk>.
479    * @return This object (for method chaining).
480    */
481   public HttpPartSchemaBuilder required(Boolean value) {
482      required = resolve(value, required);
483      return this;
484   }
485
486   /**
487    * Synonym for {@link #required(Boolean)}.
488    *
489    * @param value
490    *    The new value for this property.
491    * @return This object (for method chaining).
492    */
493   public HttpPartSchemaBuilder r(Boolean value) {
494      return required(value);
495   }
496
497   /**
498    * <mk>required</mk> field.
499    *
500    * <p>
501    * Determines whether the parameter is mandatory.
502    *
503    * <p>
504    * Same as {@link #required(Boolean)} but takes in a boolean value as a string.
505    *
506    * @param value
507    *    The new value for this property.
508    *    <br>Ignored if value is <jk>null</jk> or empty.
509    * @return This object (for method chaining).
510    */
511   public HttpPartSchemaBuilder required(String value) {
512      required = resolve(value, required);
513      return this;
514   }
515
516   /**
517    * Synonym for {@link #required(String)}.
518    *
519    * @param value
520    *    The new value for this property.
521    * @return This object (for method chaining).
522    */
523   public HttpPartSchemaBuilder r(String value) {
524      return required(value);
525   }
526
527   /**
528    * <mk>required</mk> field.
529    *
530    * <p>
531    * Shortcut for calling <code>required(<jk>true</jk>);</code>.
532    *
533    * @return This object (for method chaining).
534    */
535   public HttpPartSchemaBuilder required() {
536      return required(true);
537   }
538
539   /**
540    * Synonym for {@link #required()}.
541    *
542    * @return This object (for method chaining).
543    */
544   public HttpPartSchemaBuilder r() {
545      return required();
546   }
547
548   /**
549    * <mk>type</mk> field.
550    *
551    * <p>
552    * The type of the parameter.
553    *
554    * <p>
555    * The possible values are:
556    * <ul class='spaced-list'>
557    *    <li>
558    *       <js>"string"</js>
559    *       <br>Parameter must be a string or a POJO convertible from a string.
560    *    <li>
561    *       <js>"number"</js>
562    *       <br>Parameter must be a number primitive or number object.
563    *       <br>If parameter is <c>Object</c>, creates either a <c>Float</c> or <c>Double</c> depending on the size of the number.
564    *    <li>
565    *       <js>"integer"</js>
566    *       <br>Parameter must be a integer/long primitive or integer/long object.
567    *       <br>If parameter is <c>Object</c>, creates either a <c>Short</c>, <c>Integer</c>, or <c>Long</c> depending on the size of the number.
568    *    <li>
569    *       <js>"boolean"</js>
570    *       <br>Parameter must be a boolean primitive or object.
571    *    <li>
572    *       <js>"array"</js>
573    *       <br>Parameter must be an array or collection.
574    *       <br>Elements must be strings or POJOs convertible from strings.
575    *       <br>If parameter is <c>Object</c>, creates an {@link OList}.
576    *    <li>
577    *       <js>"object"</js>
578    *       <br>Parameter must be a map or bean.
579    *       <br>If parameter is <c>Object</c>, creates an {@link OMap}.
580    *       <br>Note that this is an extension of the OpenAPI schema as Juneau allows for arbitrarily-complex POJOs to be serialized as HTTP parts.
581    *    <li>
582    *       <js>"file"</js>
583    *       <br>This type is currently not supported.
584    * </ul>
585    *
586    * <p>
587    * If the type is not specified, it will be auto-detected based on the parameter class type.
588    *
589    * <p>
590    * Applicable to the following Swagger schema objects:
591    * <ul>
592    *    <li>{@doc ExtSwaggerParameterObject Parameter}
593    *    <li>{@doc ExtSwaggerSchemaObject Schema}
594    *    <li>{@doc ExtSwaggerItemsObject Items}
595    *    <li>{@doc ExtSwaggerSecuritySchemeObject SecurityScheme}
596    * </ul>
597    *
598    * <ul class='seealso'>
599    *    <li class='extlink'>{@doc ExtSwaggerDataTypes}
600    * </ul>
601    *
602    * @param value
603    *    The new value for this property.
604    *    <br>Ignored if value is <jk>null</jk> or empty.
605    * @return This object (for method chaining).
606    */
607   public HttpPartSchemaBuilder type(String value) {
608      try {
609         if (isNotEmpty(value))
610            type = HttpPartDataType.fromString(value);
611      } catch (Exception e) {
612         throw new ContextRuntimeException("Invalid value ''{0}'' passed in as type value.  Valid values: {1}", value, HttpPartDataType.values());
613      }
614      return this;
615   }
616
617   /**
618    * Synonym for {@link #type(String)}.
619    *
620    * @param value
621    *    The new value for this property.
622    * @return This object (for method chaining).
623    */
624   public HttpPartSchemaBuilder t(String value) {
625      return type(value);
626   }
627
628   /**
629    * Shortcut for <c>type(HttpPartDataType.STRING)</c>.
630    *
631    * @return This object (for method chaining).
632    */
633   public HttpPartSchemaBuilder tString() {
634      type = HttpPartDataType.STRING;
635      return this;
636   }
637
638   /**
639    * Shortcut for <c>type(HttpPartDataType.NUMBER)</c>.
640    *
641    * @return This object (for method chaining).
642    */
643   public HttpPartSchemaBuilder tNumber() {
644      type = HttpPartDataType.NUMBER;
645      return this;
646   }
647
648   /**
649    * Shortcut for <c>type(HttpPartDataType.INTEGER)</c>.
650    *
651    * @return This object (for method chaining).
652    */
653   public HttpPartSchemaBuilder tInteger() {
654      type = HttpPartDataType.INTEGER;
655      return this;
656   }
657
658   /**
659    * Shortcut for <c>type(HttpPartDataType.BOOLEAN)</c>.
660    *
661    * @return This object (for method chaining).
662    */
663   public HttpPartSchemaBuilder tBoolean() {
664      type = HttpPartDataType.BOOLEAN;
665      return this;
666   }
667
668   /**
669    * Shortcut for <c>type(HttpPartDataType.ARRAY)</c>.
670    *
671    * @return This object (for method chaining).
672    */
673   public HttpPartSchemaBuilder tArray() {
674      type = HttpPartDataType.ARRAY;
675      return this;
676   }
677
678   /**
679    * Shortcut for <c>type(HttpPartDataType.OBJECT)</c>.
680    *
681    * @return This object (for method chaining).
682    */
683   public HttpPartSchemaBuilder tObject() {
684      type = HttpPartDataType.OBJECT;
685      return this;
686   }
687
688   /**
689    * Shortcut for <c>type(HttpPartDataType.FILE)</c>.
690    *
691    * @return This object (for method chaining).
692    */
693   public HttpPartSchemaBuilder tFile() {
694      type = HttpPartDataType.FILE;
695      return this;
696   }
697
698   /**
699    * Shortcut for <c>type(HttpPartDataType.NO_TYPE)</c>.
700    *
701    * @return This object (for method chaining).
702    */
703   public HttpPartSchemaBuilder tNone() {
704      type = HttpPartDataType.NO_TYPE;
705      return this;
706   }
707
708   /**
709    * <mk>type</mk> field.
710    *
711    * <p>
712    * The type of the parameter.
713    *
714    * <p>
715    * The possible values are:
716    * <ul class='javatree'>
717    *    <li class='jc'>{@link HttpPartDataType}
718    *    <ul>
719    *       <li class='jf'>
720    *          {@link HttpPartDataType#STRING STRING}
721    *          <br>Parameter must be a string or a POJO convertible from a string.
722    *          <li>
723    *          {@link HttpPartDataType#NUMBER NUMBER}
724    *          <br>Parameter must be a number primitive or number object.
725    *          <br>If parameter is <c>Object</c>, creates either a <c>Float</c> or <c>Double</c> depending on the size of the number.
726    *       <li class='jf'>
727    *          {@link HttpPartDataType#INTEGER INTEGER}
728    *          <br>Parameter must be a integer/long primitive or integer/long object.
729    *          <br>If parameter is <c>Object</c>, creates either a <c>Short</c>, <c>Integer</c>, or <c>Long</c> depending on the size of the number.
730    *       <li class='jf'>
731    *          {@link HttpPartDataType#BOOLEAN BOOLEAN}
732    *          <br>Parameter must be a boolean primitive or object.
733    *       <li class='jf'>
734    *          {@link HttpPartDataType#ARRAY ARRAY}
735    *          <br>Parameter must be an array or collection.
736    *          <br>Elements must be strings or POJOs convertible from strings.
737    *          <br>If parameter is <c>Object</c>, creates an {@link OList}.
738    *       <li class='jf'>
739    *          {@link HttpPartDataType#OBJECT OBJECT}
740    *          <br>Parameter must be a map or bean.
741    *          <br>If parameter is <c>Object</c>, creates an {@link OMap}.
742    *          <br>Note that this is an extension of the OpenAPI schema as Juneau allows for arbitrarily-complex POJOs to be serialized as HTTP parts.
743    *       <li class='jf'>
744    *          {@link HttpPartDataType#FILE FILE}
745    *          <br>This type is currently not supported.
746    *    </ul>
747    * </ul>
748    *
749    * <p>
750    * If the type is not specified, it will be auto-detected based on the parameter class type.
751    *
752    * <p>
753    * Applicable to the following Swagger schema objects:
754    * <ul>
755    *    <li>{@doc ExtSwaggerParameterObject Parameter}
756    *    <li>{@doc ExtSwaggerSchemaObject Schema}
757    *    <li>{@doc ExtSwaggerItemsObject Items}
758    *    <li>{@doc ExtSwaggerSecuritySchemeObject SecurityScheme}
759    * </ul>
760    *
761    * <ul class='seealso'>
762    *    <li class='extlink'>{@doc ExtSwaggerDataTypes}
763    * </ul>
764    *
765    * @param value
766    *    The new value for this property.
767    * @return This object (for method chaining).
768    */
769   public HttpPartSchemaBuilder type(HttpPartDataType value) {
770      this.type = value;
771      return this;
772   }
773
774   /**
775    * Synonym for {@link #type(HttpPartDataType)}.
776    *
777    * @param value
778    *    The new value for this property.
779    * @return This object (for method chaining).
780    */
781   public HttpPartSchemaBuilder t(HttpPartDataType value) {
782      return type(value);
783   }
784
785   /**
786    * <mk>format</mk> field.
787    *
788    * <p>
789    * The extending format for the previously mentioned {@doc ExtSwaggerParameterTypes parameter type}.
790    *
791    * <p>
792    * The possible values are:
793    * <ul class='spaced-list'>
794    *    <li>
795    *       <js>"int32"</js> - Signed 32 bits.
796    *       <br>Only valid with type <js>"integer"</js>.
797    *    <li>
798    *       <js>"int64"</js> - Signed 64 bits.
799    *       <br>Only valid with type <js>"integer"</js>.
800    *    <li>
801    *       <js>"float"</js> - 32-bit floating point number.
802    *       <br>Only valid with type <js>"number"</js>.
803    *    <li>
804    *       <js>"double"</js> - 64-bit floating point number.
805    *       <br>Only valid with type <js>"number"</js>.
806    *    <li>
807    *       <js>"byte"</js> - BASE-64 encoded characters.
808    *       <br>Only valid with type <js>"string"</js>.
809    *       <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
810    *    <li>
811    *       <js>"binary"</js> - Hexadecimal encoded octets (e.g. <js>"00FF"</js>).
812    *       <br>Only valid with type <js>"string"</js>.
813    *       <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
814    *    <li>
815    *       <js>"binary-spaced"</js> - Hexadecimal encoded octets, spaced (e.g. <js>"00 FF"</js>).
816    *       <br>Only valid with type <js>"string"</js>.
817    *       <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
818    *    <li>
819    *       <js>"date"</js> - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>.
820    *       <br>Only valid with type <js>"string"</js>.
821    *    <li>
822    *       <js>"date-time"</js> - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>.
823    *       <br>Only valid with type <js>"string"</js>.
824    *    <li>
825    *       <js>"password"</js> - Used to hint UIs the input needs to be obscured.
826    *       <br>This format does not affect the serialization or parsing of the parameter.
827    *    <li>
828    *       <js>"uon"</js> - UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>).
829    *       <br>Only valid with type <js>"object"</js>.
830    *       <br>If not specified, then the input is interpreted as plain-text and is converted to a POJO directly.
831    * </ul>
832    *
833    * <p>
834    * Applicable to the following Swagger schema objects:
835    * <ul>
836    *    <li>{@doc ExtSwaggerParameterObject Parameter}
837    *    <li>{@doc ExtSwaggerSchemaObject Schema}
838    *    <li>{@doc ExtSwaggerItemsObject Items}
839    *    <li>{@doc ExtSwaggerHeaderObject Header}
840    * </ul>
841    *
842    * <ul class='seealso'>
843    *    <li class='extlink'>{@doc ExtSwaggerDataTypeFormats}
844    * </ul>
845    *
846    * @param value
847    *    The new value for this property.
848    *    <br>Ignored if value is <jk>null</jk> or an empty string.
849    * @return This object (for method chaining).
850    */
851   public HttpPartSchemaBuilder format(String value) {
852      try {
853         if (isNotEmpty(value))
854            format = HttpPartFormat.fromString(value);
855      } catch (Exception e) {
856         throw new ContextRuntimeException("Invalid value ''{0}'' passed in as format value.  Valid values: {1}", value, HttpPartFormat.values());
857      }
858      return this;
859   }
860
861   /**
862    * Synonym for {@link #format(String)}.
863    *
864    * @param value
865    *    The new value for this property.
866    * @return This object (for method chaining).
867    */
868   public HttpPartSchemaBuilder f(String value) {
869      return format(value);
870   }
871
872   /**
873    * <mk>format</mk> field.
874    *
875    * <p>
876    * The extending format for the previously mentioned {@doc ExtSwaggerParameterTypes parameter type}.
877    *
878    * <p>
879    * The possible values are:
880    * <ul class='javatree'>
881    *    <ul class='jc'>{@link HttpPartFormat}
882    *    <ul>
883    *       <li class='jf'>
884    *          {@link HttpPartFormat#INT32 INT32} - Signed 32 bits.
885    *          <br>Only valid with type <js>"integer"</js>.
886    *       <li class='jf'>
887    *          {@link HttpPartFormat#INT64 INT64} - Signed 64 bits.
888    *          <br>Only valid with type <js>"integer"</js>.
889    *       <li class='jf'>
890    *          {@link HttpPartFormat#FLOAT FLOAT} - 32-bit floating point number.
891    *          <br>Only valid with type <js>"number"</js>.
892    *       <li class='jf'>
893    *          {@link HttpPartFormat#DOUBLE DOUBLE} - 64-bit floating point number.
894    *          <br>Only valid with type <js>"number"</js>.
895    *       <li class='jf'>
896    *          {@link HttpPartFormat#BYTE BYTE} - BASE-64 encoded characters.
897    *          <br>Only valid with type <js>"string"</js>.
898    *          <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
899    *       <li class='jf'>
900    *          {@link HttpPartFormat#BINARY BINARY} - Hexadecimal encoded octets (e.g. <js>"00FF"</js>).
901    *          <br>Only valid with type <js>"string"</js>.
902    *          <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
903    *       <li class='jf'>
904    *          {@link HttpPartFormat#BINARY_SPACED BINARY_SPACED} - Hexadecimal encoded octets, spaced (e.g. <js>"00 FF"</js>).
905    *          <br>Only valid with type <js>"string"</js>.
906    *          <br>Parameters of type POJO convertible from string are converted after the string has been decoded.
907    *       <li class='jf'>
908    *          {@link HttpPartFormat#DATE DATE} - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>.
909    *          <br>Only valid with type <js>"string"</js>.
910    *       <li class='jf'>
911    *          {@link HttpPartFormat#DATE_TIME DATE_TIME} - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>.
912    *          <br>Only valid with type <js>"string"</js>.
913    *       <li class='jf'>
914    *          {@link HttpPartFormat#PASSWORD PASSWORD} - Used to hint UIs the input needs to be obscured.
915    *          <br>This format does not affect the serialization or parsing of the parameter.
916    *       <li class='jf'>
917    *          {@link HttpPartFormat#UON UON} - UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>).
918    *          <br>Only valid with type <js>"object"</js>.
919    *          <br>If not specified, then the input is interpreted as plain-text and is converted to a POJO directly.
920    *    </ul>
921    * </ul>
922    *
923    * <p>
924    * Applicable to the following Swagger schema objects:
925    * <ul>
926    *    <li>{@doc ExtSwaggerParameterObject Parameter}
927    *    <li>{@doc ExtSwaggerSchemaObject Schema}
928    *    <li>{@doc ExtSwaggerItemsObject Items}
929    *    <li>{@doc ExtSwaggerHeaderObject Header}
930    * </ul>
931    *
932    * <ul class='seealso'>
933    *    <li class='extlink'>{@doc ExtSwaggerDataTypeFormats}
934    * </ul>
935    *
936    * @param value
937    *    The new value for this property.
938    * @return This object (for method chaining).
939    */
940   public HttpPartSchemaBuilder format(HttpPartFormat value) {
941      format = value;
942      return this;
943   }
944
945   /**
946    * Synonym for {@link #format(HttpPartFormat)}.
947    *
948    * @param value
949    *    The new value for this property.
950    * @return This object (for method chaining).
951    */
952   public HttpPartSchemaBuilder f(HttpPartFormat value) {
953      return format(value);
954   }
955
956   /**
957    * Shortcut for <c>format(HttpPartFormat.INT32)</c>.
958    *
959    * @return This object (for method chaining).
960    */
961   public HttpPartSchemaBuilder fInt32() {
962      format = HttpPartFormat.INT32;
963      return this;
964   }
965
966   /**
967    * Shortcut for <c>format(HttpPartFormat.INT64)</c>.
968    *
969    * @return This object (for method chaining).
970    */
971   public HttpPartSchemaBuilder fInt64() {
972      format = HttpPartFormat.INT64;
973      return this;
974   }
975
976   /**
977    * Shortcut for <c>format(HttpPartFormat.FLOAT)</c>.
978    *
979    * @return This object (for method chaining).
980    */
981   public HttpPartSchemaBuilder fFloat() {
982      format = HttpPartFormat.FLOAT;
983      return this;
984   }
985
986   /**
987    * Shortcut for <c>format(HttpPartFormat.DOUBLE)</c>.
988    *
989    * @return This object (for method chaining).
990    */
991   public HttpPartSchemaBuilder fDouble() {
992      format = HttpPartFormat.DOUBLE;
993      return this;
994   }
995
996   /**
997    * Shortcut for <c>format(HttpPartFormat.BYTE)</c>.
998    *
999    * @return This object (for method chaining).
1000    */
1001   public HttpPartSchemaBuilder fByte() {
1002      format = HttpPartFormat.BYTE;
1003      return this;
1004   }
1005
1006   /**
1007    * Shortcut for <c>format(HttpPartFormat.BINARY)</c>.
1008    *
1009    * @return This object (for method chaining).
1010    */
1011   public HttpPartSchemaBuilder fBinary() {
1012      format = HttpPartFormat.BINARY;
1013      return this;
1014   }
1015
1016   /**
1017    * Shortcut for <c>format(HttpPartFormat.BINARY_SPACED)</c>.
1018    *
1019    * @return This object (for method chaining).
1020    */
1021   public HttpPartSchemaBuilder fBinarySpaced() {
1022      format = HttpPartFormat.BINARY_SPACED;
1023      return this;
1024   }
1025
1026   /**
1027    * Shortcut for <c>format(HttpPartFormat.DATE)</c>.
1028    *
1029    * @return This object (for method chaining).
1030    */
1031   public HttpPartSchemaBuilder fDate() {
1032      format = HttpPartFormat.DATE;
1033      return this;
1034   }
1035
1036   /**
1037    * Shortcut for <c>format(HttpPartFormat.DATE_TIME)</c>.
1038    *
1039    * @return This object (for method chaining).
1040    */
1041   public HttpPartSchemaBuilder fDateTime() {
1042      format = HttpPartFormat.DATE_TIME;
1043      return this;
1044   }
1045
1046   /**
1047    * Shortcut for <c>format(HttpPartFormat.PASSWORD)</c>.
1048    *
1049    * @return This object (for method chaining).
1050    */
1051   public HttpPartSchemaBuilder fPassword() {
1052      format = HttpPartFormat.PASSWORD;
1053      return this;
1054   }
1055
1056   /**
1057    * Shortcut for <c>format(HttpPartFormat.UON)</c>.
1058    *
1059    * @return This object (for method chaining).
1060    */
1061   public HttpPartSchemaBuilder fUon() {
1062      format = HttpPartFormat.UON;
1063      return this;
1064   }
1065
1066   /**
1067    * Shortcut for <c>format(HttpPartFormat.NO_FORMAT)</c>.
1068    *
1069    * @return This object (for method chaining).
1070    */
1071   public HttpPartSchemaBuilder fNone() {
1072      format = HttpPartFormat.NO_FORMAT;
1073      return this;
1074   }
1075
1076   /**
1077    * <mk>allowEmptyValue</mk> field.
1078    *
1079    * <p>
1080    * Sets the ability to pass empty-valued parameters.
1081    * <br>This is valid only for either query or formData parameters and allows you to send a parameter with a name only or an empty value.
1082    * <br>The default value is <jk>false</jk>.
1083    *
1084    * <p>
1085    * Applicable to the following Swagger schema objects:
1086    * <ul>
1087    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1088    * </ul>
1089    *
1090    * @param value
1091    *    The new value for this property.
1092    *    <br>Ignored if value is <jk>null</jk>.
1093    * @return This object (for method chaining).
1094    */
1095   public HttpPartSchemaBuilder allowEmptyValue(Boolean value) {
1096      allowEmptyValue = resolve(value, allowEmptyValue);
1097      return this;
1098   }
1099
1100   /**
1101    * Synonym for {@link #allowEmptyValue(Boolean)}.
1102    *
1103    * @param value
1104    *    The new value for this property.
1105    * @return This object (for method chaining).
1106    */
1107   public HttpPartSchemaBuilder aev(Boolean value) {
1108      return allowEmptyValue(value);
1109   }
1110
1111   /**
1112    * <mk>allowEmptyValue</mk> field.
1113    *
1114    * <p>
1115    * Same as {@link #allowEmptyValue(Boolean)} but takes in a string boolean value.
1116    *
1117    * @param value
1118    *    The new value for this property.
1119    *    <br>Ignored if value is <jk>null</jk> or empty.
1120    * @return This object (for method chaining).
1121    */
1122   public HttpPartSchemaBuilder allowEmptyValue(String value) {
1123      allowEmptyValue = resolve(value, allowEmptyValue);
1124      return this;
1125   }
1126
1127   /**
1128    * Synonym for {@link #allowEmptyValue(String)}.
1129    *
1130    * @param value
1131    *    The new value for this property.
1132    * @return This object (for method chaining).
1133    */
1134   public HttpPartSchemaBuilder aev(String value) {
1135      return allowEmptyValue(value);
1136   }
1137
1138   /**
1139    * <mk>allowEmptyValue</mk> field.
1140    *
1141    * <p>
1142    * Shortcut for calling <code>allowEmptyValue(<jk>true</jk>);</code>.
1143    *
1144    * @return This object (for method chaining).
1145    */
1146   public HttpPartSchemaBuilder allowEmptyValue() {
1147      return allowEmptyValue(true);
1148   }
1149
1150   /**
1151    * Synonym for {@link #allowEmptyValue()}.
1152    *
1153    * @return This object (for method chaining).
1154    */
1155   public HttpPartSchemaBuilder aev() {
1156      return allowEmptyValue(true);
1157   }
1158
1159   /**
1160    * <mk>items</mk> field.
1161    *
1162    * <p>
1163    * Describes the type of items in the array.
1164    * <p>
1165    * Required if <c>type</c> is <js>"array"</js>.
1166    * <br>Can only be used if <c>type</c> is <js>"array"</js>.
1167    *
1168    * <p>
1169    * Applicable to the following Swagger schema objects:
1170    * <ul>
1171    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1172    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1173    *    <li>{@doc ExtSwaggerItemsObject Items}
1174    *    <li>{@doc ExtSwaggerHeaderObject Header}
1175    * </ul>
1176    *
1177    * @param value
1178    *    The new value for this property.
1179    *    <br>Ignored if value is <jk>null</jk> or empty.
1180    * @return This object (for method chaining).
1181    */
1182   public HttpPartSchemaBuilder items(HttpPartSchemaBuilder value) {
1183      if (value != null)
1184         this.items = value;
1185      return this;
1186   }
1187
1188   /**
1189    * Synonym for {@link #items(HttpPartSchemaBuilder)}.
1190    *
1191    * @param value
1192    *    The new value for this property.
1193    * @return This object (for method chaining).
1194    */
1195   public HttpPartSchemaBuilder i(HttpPartSchemaBuilder value) {
1196      return items(value);
1197   }
1198
1199   /**
1200    * <mk>items</mk> field.
1201    *
1202    * <p>
1203    * Describes the type of items in the array.
1204    * <p>
1205    * Required if <c>type</c> is <js>"array"</js>.
1206    * <br>Can only be used if <c>type</c> is <js>"array"</js>.
1207    *
1208    * <p>
1209    * Applicable to the following Swagger schema objects:
1210    * <ul>
1211    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1212    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1213    *    <li>{@doc ExtSwaggerItemsObject Items}
1214    *    <li>{@doc ExtSwaggerHeaderObject Header}
1215    * </ul>
1216    *
1217    * @param value
1218    *    The new value for this property.
1219    *    <br>Ignored if value is <jk>null</jk> or empty.
1220    * @return This object (for method chaining).
1221    */
1222   public HttpPartSchemaBuilder items(HttpPartSchema value) {
1223      if (value != null)
1224         this.items = value;
1225      return this;
1226   }
1227
1228   /**
1229    * Synonym for {@link #items(HttpPartSchema)}.
1230    *
1231    * @param value
1232    *    The new value for this property.
1233    * @return This object (for method chaining).
1234    */
1235   public HttpPartSchemaBuilder i(HttpPartSchema value) {
1236      return items(value);
1237   }
1238
1239   HttpPartSchemaBuilder items(OMap value) {
1240      if (value != null && ! value.isEmpty())
1241         items = HttpPartSchema.create().apply(value);
1242      return this;
1243   }
1244
1245   HttpPartSchemaBuilder items(Items value) {
1246      if (! AnnotationUtils.empty(value))
1247         items = HttpPartSchema.create().apply(value);
1248      return this;
1249   }
1250
1251   HttpPartSchemaBuilder items(SubItems value) {
1252      if (! AnnotationUtils.empty(value))
1253         items = HttpPartSchema.create().apply(value);
1254      return this;
1255   }
1256
1257
1258   /**
1259    * <mk>collectionFormat</mk> field.
1260    *
1261    * <p>
1262    * Determines the format of the array if <c>type</c> <js>"array"</js> is used.
1263    * <br>Can only be used if <c>type</c> is <js>"array"</js>.
1264    *
1265    * <br>Possible values are:
1266    * <ul class='spaced-list'>
1267    *    <li>
1268    *       <js>"csv"</js> (default) - Comma-separated values (e.g. <js>"foo,bar"</js>).
1269    *    <li>
1270    *       <js>"ssv"</js> - Space-separated values (e.g. <js>"foo bar"</js>).
1271    *    <li>
1272    *       <js>"tsv"</js> - Tab-separated values (e.g. <js>"foo\tbar"</js>).
1273    *    <li>
1274    *       <js>"pipes</js> - Pipe-separated values (e.g. <js>"foo|bar"</js>).
1275    *    <li>
1276    *       <js>"multi"</js> - Corresponds to multiple parameter instances instead of multiple values for a single instance (e.g. <js>"foo=bar&amp;foo=baz"</js>).
1277    *    <li>
1278    *       <js>"uon"</js> - UON notation (e.g. <js>"@(foo,bar)"</js>).
1279    *    <li>
1280    * </ul>
1281    *
1282    * <p>
1283    * Applicable to the following Swagger schema objects:
1284    * <ul>
1285    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1286    *    <li>{@doc ExtSwaggerItemsObject Items}
1287    *    <li>{@doc ExtSwaggerHeaderObject Header}
1288    * </ul>
1289    *
1290    * <p>
1291    * Note that for collections/arrays parameters with POJO element types, the input is broken into a string array before being converted into POJO elements.
1292    *
1293    * @param value
1294    *    The new value for this property.
1295    *    <br>Ignored if value is <jk>null</jk> or empty.
1296    * @return This object (for method chaining).
1297    */
1298   public HttpPartSchemaBuilder collectionFormat(String value) {
1299      try {
1300         if (isNotEmpty(value))
1301            this.collectionFormat = HttpPartCollectionFormat.fromString(value);
1302      } catch (Exception e) {
1303         throw new ContextRuntimeException("Invalid value ''{0}'' passed in as collectionFormat value.  Valid values: {1}", value, HttpPartCollectionFormat.values());
1304      }
1305      return this;
1306   }
1307
1308   /**
1309    * Synonym for {@link #collectionFormat(String)}.
1310    *
1311    * @param value
1312    *    The new value for this property.
1313    * @return This object (for method chaining).
1314    */
1315   public HttpPartSchemaBuilder cf(String value) {
1316      return collectionFormat(value);
1317   }
1318
1319   /**
1320    * <mk>collectionFormat</mk> field.
1321    *
1322    * <p>
1323    * Determines the format of the array if <c>type</c> <js>"array"</js> is used.
1324    * <br>Can only be used if <c>type</c> is <js>"array"</js>.
1325    *
1326    * <br>Possible values are:
1327    * <ul class='javatree'>
1328    *    <ul class='jc'>{@link HttpPartCollectionFormat}
1329    *    <ul>
1330    *       <li>
1331    *          {@link HttpPartCollectionFormat#CSV CSV} (default) - Comma-separated values (e.g. <js>"foo,bar"</js>).
1332    *       <li>
1333    *          {@link HttpPartCollectionFormat#SSV SSV} - Space-separated values (e.g. <js>"foo bar"</js>).
1334    *       <li>
1335    *          {@link HttpPartCollectionFormat#TSV TSV} - Tab-separated values (e.g. <js>"foo\tbar"</js>).
1336    *       <li>
1337    *          {@link HttpPartCollectionFormat#PIPES PIPES} - Pipe-separated values (e.g. <js>"foo|bar"</js>).
1338    *       <li>
1339    *          {@link 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>).
1340    *       <li>
1341    *          {@link HttpPartCollectionFormat#UONC UONC} - UON collection notation (e.g. <js>"@(foo,bar)"</js>).
1342    *    </ul>
1343    * </ul>
1344    *
1345    * <p>
1346    * Applicable to the following Swagger schema objects:
1347    * <ul>
1348    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1349    *    <li>{@doc ExtSwaggerItemsObject Items}
1350    *    <li>{@doc ExtSwaggerHeaderObject Header}
1351    * </ul>
1352    *
1353    * <p>
1354    * Note that for collections/arrays parameters with POJO element types, the input is broken into a string array before being converted into POJO elements.
1355    *
1356    * @param value
1357    *    The new value for this property.
1358    * @return This object (for method chaining).
1359    */
1360   public HttpPartSchemaBuilder collectionFormat(HttpPartCollectionFormat value) {
1361      collectionFormat = value;
1362      return this;
1363   }
1364
1365   /**
1366    * Synonym for {@link #collectionFormat(HttpPartCollectionFormat)}.
1367    *
1368    * @param value
1369    *    The new value for this property.
1370    * @return This object (for method chaining).
1371    */
1372   public HttpPartSchemaBuilder cf(HttpPartCollectionFormat value) {
1373      return collectionFormat(value);
1374   }
1375
1376   /**
1377    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.CSV)</c>.
1378    *
1379    * @return This object (for method chaining).
1380    */
1381   public HttpPartSchemaBuilder cfCsv() {
1382      return collectionFormat(HttpPartCollectionFormat.CSV);
1383   }
1384
1385   /**
1386    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.SSV)</c>.
1387    *
1388    * @return This object (for method chaining).
1389    */
1390   public HttpPartSchemaBuilder cfSsv() {
1391      return collectionFormat(HttpPartCollectionFormat.SSV);
1392   }
1393
1394   /**
1395    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.TSV)</c>.
1396    *
1397    * @return This object (for method chaining).
1398    */
1399   public HttpPartSchemaBuilder cfTsv() {
1400      return collectionFormat(HttpPartCollectionFormat.TSV);
1401   }
1402
1403   /**
1404    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.PIPES)</c>.
1405    *
1406    * @return This object (for method chaining).
1407    */
1408   public HttpPartSchemaBuilder cfPipes() {
1409      return collectionFormat(HttpPartCollectionFormat.PIPES);
1410   }
1411
1412   /**
1413    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.MULTI)</c>.
1414    *
1415    * @return This object (for method chaining).
1416    */
1417   public HttpPartSchemaBuilder cfMulti() {
1418      return collectionFormat(HttpPartCollectionFormat.MULTI);
1419   }
1420
1421   /**
1422    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.UONC)</c>.
1423    *
1424    * @return This object (for method chaining).
1425    */
1426   public HttpPartSchemaBuilder cfUon() {
1427      return collectionFormat(HttpPartCollectionFormat.UONC);
1428   }
1429
1430   /**
1431    * Shortcut for <c>collectionFormat(HttpPartCollectionFormat.NO_COLLECTION_FORMAT)</c>.
1432    *
1433    * @return This object (for method chaining).
1434    */
1435   public HttpPartSchemaBuilder cfNone() {
1436      return collectionFormat(HttpPartCollectionFormat.NO_COLLECTION_FORMAT);
1437   }
1438
1439   /**
1440    * <mk>default</mk> field.
1441    *
1442    * <p>
1443    * Declares the value of the parameter that the server will use if none is provided, for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
1444    * <br>(Note: "default" has no meaning for required parameters.)
1445    *
1446    * <p>
1447    * Applicable to the following Swagger schema objects:
1448    * <ul>
1449    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1450    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1451    *    <li>{@doc ExtSwaggerItemsObject Items}
1452    *    <li>{@doc ExtSwaggerHeaderObject Header}
1453    * </ul>
1454    *
1455    * @param value
1456    *    The new value for this property.
1457    *    <br>Ignored if value is <jk>null</jk>.
1458    * @return This object (for method chaining).
1459    */
1460   public HttpPartSchemaBuilder _default(String value) {
1461      if (value != null)
1462         this._default = value;
1463      return this;
1464   }
1465
1466   /**
1467    * Synonym for {@link #_default(String)}.
1468    *
1469    * @param value
1470    *    The new value for this property.
1471    * @return This object (for method chaining).
1472    */
1473   public HttpPartSchemaBuilder df(String value) {
1474      return _default(value);
1475   }
1476
1477   /**
1478    * <mk>maximum</mk> field.
1479    *
1480    * <p>
1481    * Defines the maximum value for a parameter of numeric types.
1482    *
1483    * <p>
1484    * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>.
1485    *
1486    * <p>
1487    * Applicable to the following Swagger schema objects:
1488    * <ul>
1489    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1490    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1491    *    <li>{@doc ExtSwaggerItemsObject Items}
1492    *    <li>{@doc ExtSwaggerHeaderObject Header}
1493    * </ul>
1494    *
1495    * @param value
1496    *    The new value for this property.
1497    *    <br>Ignored if value is <jk>null</jk>.
1498    * @return This object (for method chaining).
1499    */
1500   public HttpPartSchemaBuilder maximum(Number value) {
1501      if (value != null)
1502         this.maximum = value;
1503      return this;
1504   }
1505
1506   /**
1507    * Synonym for {@link #maximum(Number)}.
1508    *
1509    * @param value
1510    *    The new value for this property.
1511    * @return This object (for method chaining).
1512    */
1513   public HttpPartSchemaBuilder max(Number value) {
1514      return maximum(value);
1515   }
1516
1517   /**
1518    * <mk>exclusiveMaximum</mk> field.
1519    *
1520    * <p>
1521    * Defines whether the maximum is matched exclusively.
1522    *
1523    * <p>
1524    * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>.
1525    * <br>If <jk>true</jk>, must be accompanied with <c>maximum</c>.
1526    *
1527    * <p>
1528    * Applicable to the following Swagger schema objects:
1529    * <ul>
1530    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1531    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1532    *    <li>{@doc ExtSwaggerItemsObject Items}
1533    *    <li>{@doc ExtSwaggerHeaderObject Header}
1534    * </ul>
1535    *
1536    * @param value
1537    *    The new value for this property.
1538    *    <br>Ignored if value is <jk>null</jk>.
1539    * @return This object (for method chaining).
1540    */
1541   public HttpPartSchemaBuilder exclusiveMaximum(Boolean value) {
1542      exclusiveMaximum = resolve(value, exclusiveMaximum);
1543      return this;
1544   }
1545
1546   /**
1547    * Synonym for {@link #exclusiveMaximum(Boolean)}.
1548    *
1549    * @param value
1550    *    The new value for this property.
1551    * @return This object (for method chaining).
1552    */
1553   public HttpPartSchemaBuilder emax(Boolean value) {
1554      return exclusiveMaximum(value);
1555   }
1556
1557   /**
1558    * <mk>exclusiveMaximum</mk> field.
1559    *
1560    * <p>
1561    * Same as {@link #exclusiveMaximum(Boolean)} but takes in a string boolean value.
1562    *
1563    * @param value
1564    *    The new value for this property.
1565    *    <br>Ignored if value is <jk>null</jk> or empty.
1566    * @return This object (for method chaining).
1567    */
1568   public HttpPartSchemaBuilder exclusiveMaximum(String value) {
1569      exclusiveMaximum = resolve(value, exclusiveMaximum);
1570      return this;
1571   }
1572
1573   /**
1574    * Synonym for {@link #exclusiveMaximum(String)}.
1575    *
1576    * @param value
1577    *    The new value for this property.
1578    * @return This object (for method chaining).
1579    */
1580   public HttpPartSchemaBuilder emax(String value) {
1581      return exclusiveMaximum(value);
1582   }
1583
1584   /**
1585    * <mk>exclusiveMaximum</mk> field.
1586    *
1587    * <p>
1588    * Shortcut for calling <code>exclusiveMaximum(<jk>true</jk>);</code>.
1589    *
1590    * @return This object (for method chaining).
1591    */
1592   public HttpPartSchemaBuilder exclusiveMaximum() {
1593      return exclusiveMaximum(true);
1594   }
1595
1596   /**
1597    * Synonym for {@link #exclusiveMaximum()}.
1598    *
1599    * @return This object (for method chaining).
1600    */
1601   public HttpPartSchemaBuilder emax() {
1602      return exclusiveMaximum();
1603   }
1604
1605   /**
1606    * <mk>minimum</mk> field.
1607    *
1608    * <p>
1609    * Defines the minimum value for a parameter of numeric types.
1610    *
1611    * <p>
1612    * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>.
1613    *
1614    * <p>
1615    * Applicable to the following Swagger schema objects:
1616    * <ul>
1617    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1618    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1619    *    <li>{@doc ExtSwaggerItemsObject Items}
1620    *    <li>{@doc ExtSwaggerHeaderObject Header}
1621    * </ul>
1622    *
1623    * @param value
1624    *    The new value for this property.
1625    *    <br>Ignored if value is <jk>null</jk>.
1626    * @return This object (for method chaining).
1627    */
1628   public HttpPartSchemaBuilder minimum(Number value) {
1629      if (value != null)
1630         this.minimum = value;
1631      return this;
1632   }
1633
1634   /**
1635    * Synonym for {@link #minimum(Number)}.
1636    *
1637    * @param value
1638    *    The new value for this property.
1639    * @return This object (for method chaining).
1640    */
1641   public HttpPartSchemaBuilder min(Number value) {
1642      return minimum(value);
1643   }
1644
1645   /**
1646    * <mk>exclusiveMinimum</mk> field.
1647    *
1648    * <p>
1649    * Defines whether the minimum is matched exclusively.
1650    *
1651    * <p>
1652    * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>.
1653    * <br>If <jk>true</jk>, must be accompanied with <c>minimum</c>.
1654    *
1655    * <p>
1656    * Applicable to the following Swagger schema objects:
1657    * <ul>
1658    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1659    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1660    *    <li>{@doc ExtSwaggerItemsObject Items}
1661    *    <li>{@doc ExtSwaggerHeaderObject Header}
1662    * </ul>
1663    *
1664    * @param value
1665    *    The new value for this property.
1666    *    <br>Ignored if value is <jk>null</jk>.
1667    * @return This object (for method chaining).
1668    */
1669   public HttpPartSchemaBuilder exclusiveMinimum(Boolean value) {
1670      exclusiveMinimum = resolve(value, exclusiveMinimum);
1671      return this;
1672   }
1673
1674   /**
1675    * Synonym for {@link #exclusiveMinimum(Boolean)}.
1676    *
1677    * @param value
1678    *    The new value for this property.
1679    * @return This object (for method chaining).
1680    */
1681   public HttpPartSchemaBuilder emin(Boolean value) {
1682      return exclusiveMinimum(value);
1683   }
1684
1685   /**
1686    * <mk>exclusiveMinimum</mk> field.
1687    *
1688    * <p>
1689    * Same as {@link #exclusiveMinimum(Boolean)} but takes in a string boolean value.
1690    *
1691    * @param value
1692    *    The new value for this property.
1693    *    <br>Ignored if value is <jk>null</jk> or empty.
1694    * @return This object (for method chaining).
1695    */
1696   public HttpPartSchemaBuilder exclusiveMinimum(String value) {
1697      exclusiveMinimum = resolve(value, exclusiveMinimum);
1698      return this;
1699   }
1700
1701   /**
1702    * Synonym for {@link #exclusiveMinimum(String)}.
1703    *
1704    * @param value
1705    *    The new value for this property.
1706    * @return This object (for method chaining).
1707    */
1708   public HttpPartSchemaBuilder emin(String value) {
1709      return exclusiveMinimum(value);
1710   }
1711
1712   /**
1713    * <mk>exclusiveMinimum</mk> field.
1714    *
1715    * <p>
1716    * Shortcut for calling <code>exclusiveMinimum(<jk>true</jk>);</code>.
1717    *
1718    * @return This object (for method chaining).
1719    */
1720   public HttpPartSchemaBuilder exclusiveMinimum() {
1721      return exclusiveMinimum(true);
1722   }
1723
1724   /**
1725    * Synonym for {@link #exclusiveMinimum()}.
1726    *
1727    * @return This object (for method chaining).
1728    */
1729   public HttpPartSchemaBuilder emin() {
1730      return exclusiveMinimum();
1731   }
1732
1733   /**
1734    * <mk>maxLength</mk> field.
1735    *
1736    * <p>
1737    * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.
1738    * <br>The length of a string instance is defined as the number of its characters as defined by <a href='https://tools.ietf.org/html/rfc4627'>RFC 4627</a>.
1739    *
1740    * <p>
1741    * Only allowed for the following types: <js>"string"</js>.
1742    *
1743    * <p>
1744    * Applicable to the following Swagger schema objects:
1745    * <ul>
1746    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1747    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1748    *    <li>{@doc ExtSwaggerItemsObject Items}
1749    *    <li>{@doc ExtSwaggerHeaderObject Header}
1750    * </ul>
1751    *
1752    * @param value
1753    *    The new value for this property.
1754    *    <br>Ignored if value is <jk>null</jk> or <c>-1</c>.
1755    * @return This object (for method chaining).
1756    */
1757   public HttpPartSchemaBuilder maxLength(Long value) {
1758      maxLength = resolve(value, maxLength);
1759      return this;
1760   }
1761
1762   /**
1763    * Synonym for {@link #maxLength(Long)}.
1764    *
1765    * @param value
1766    *    The new value for this property.
1767    * @return This object (for method chaining).
1768    */
1769   public HttpPartSchemaBuilder maxl(Long value) {
1770      return maxLength(value);
1771   }
1772
1773   /**
1774    * <mk>maxLength</mk> field.
1775    *
1776    * <p>
1777    * Same as {@link #maxLength(Long)} but takes in a string number.
1778    *
1779    * @param value
1780    *    The new value for this property.
1781    *    <br>Ignored if value is <jk>null</jk> or empty.
1782    * @return This object (for method chaining).
1783    */
1784   public HttpPartSchemaBuilder maxLength(String value) {
1785      maxLength = resolve(value, maxLength);
1786      return this;
1787   }
1788
1789   /**
1790    * Synonym for {@link #maxLength(String)}.
1791    *
1792    * @param value
1793    *    The new value for this property.
1794    * @return This object (for method chaining).
1795    */
1796   public HttpPartSchemaBuilder maxl(String value) {
1797      return maxLength(value);
1798   }
1799
1800   /**
1801    * <mk>minLength</mk> field.
1802    *
1803    * <p>
1804    * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword.
1805    * <br>The length of a string instance is defined as the number of its characters as defined by <a href='https://tools.ietf.org/html/rfc4627'>RFC 4627</a>.
1806    *
1807    * <p>
1808    * Only allowed for the following types: <js>"string"</js>.
1809    *
1810    * <p>
1811    * Applicable to the following Swagger schema objects:
1812    * <ul>
1813    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1814    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1815    *    <li>{@doc ExtSwaggerItemsObject Items}
1816    *    <li>{@doc ExtSwaggerHeaderObject Header}
1817    * </ul>
1818    *
1819    * @param value
1820    *    The new value for this property.
1821    *    <br>Ignored if value is <jk>null</jk> or <c>-1</c>.
1822    * @return This object (for method chaining).
1823    */
1824   public HttpPartSchemaBuilder minLength(Long value) {
1825      minLength = resolve(value, minLength);
1826      return this;
1827   }
1828
1829   /**
1830    * Synonym for {@link #minLength(Long)}.
1831    *
1832    * @param value
1833    *    The new value for this property.
1834    * @return This object (for method chaining).
1835    */
1836   public HttpPartSchemaBuilder minl(Long value) {
1837      return minLength(value);
1838   }
1839
1840   /**
1841    * <mk>minLength</mk> field.
1842    *
1843    * <p>
1844    * Same as {@link #minLength(Long)} but takes in a string number.
1845    *
1846    * @param value
1847    *    The new value for this property.
1848    *    <br>Ignored if value is <jk>null</jk> or empty.
1849    * @return This object (for method chaining).
1850    */
1851   public HttpPartSchemaBuilder minLength(String value) {
1852      minLength = resolve(value, minLength);
1853      return this;
1854   }
1855
1856   /**
1857    * Synonym for {@link #minLength(String)}.
1858    *
1859    * @param value
1860    *    The new value for this property.
1861    * @return This object (for method chaining).
1862    */
1863   public HttpPartSchemaBuilder minl(String value) {
1864      return minLength(value);
1865   }
1866
1867   /**
1868    * <mk>pattern</mk> field.
1869    *
1870    * <p>
1871    * A string input is valid if it matches the specified regular expression pattern.
1872    *
1873    * <p>
1874    * Only allowed for the following types: <js>"string"</js>.
1875    *
1876    * <p>
1877    * Applicable to the following Swagger schema objects:
1878    * <ul>
1879    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1880    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1881    *    <li>{@doc ExtSwaggerItemsObject Items}
1882    *    <li>{@doc ExtSwaggerHeaderObject Header}
1883    * </ul>
1884    *
1885    * @param value
1886    *    The new value for this property.
1887    *    <br>Ignored if value is <jk>null</jk> or empty.
1888    * @return This object (for method chaining).
1889    */
1890   public HttpPartSchemaBuilder pattern(String value) {
1891      try {
1892         if (isNotEmpty(value))
1893            this.pattern = Pattern.compile(value);
1894      } catch (Exception e) {
1895         throw new ContextRuntimeException(e, "Invalid value {0} passed in as pattern value.  Must be a valid regular expression.", value);
1896      }
1897      return this;
1898   }
1899
1900   /**
1901    * Synonym for {@link #pattern(String)}.
1902    *
1903    * @param value
1904    *    The new value for this property.
1905    * @return This object (for method chaining).
1906    */
1907   public HttpPartSchemaBuilder p(String value) {
1908      return pattern(value);
1909   }
1910
1911   /**
1912    * <mk>maxItems</mk> field.
1913    *
1914    * <p>
1915    * An array or collection is valid if its size is less than, or equal to, the value of this keyword.
1916    *
1917    * <p>
1918    * Only allowed for the following types: <js>"array"</js>.
1919    *
1920    * <p>
1921    * Applicable to the following Swagger schema objects:
1922    * <ul>
1923    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1924    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1925    *    <li>{@doc ExtSwaggerItemsObject Items}
1926    *    <li>{@doc ExtSwaggerHeaderObject Header}
1927    * </ul>
1928    *
1929    * @param value
1930    *    The new value for this property.
1931    *    <br>Ignored if value is <jk>null</jk> or <c>-1</c>.
1932    * @return This object (for method chaining).
1933    */
1934   public HttpPartSchemaBuilder maxItems(Long value) {
1935      maxItems = resolve(value, maxItems);
1936      return this;
1937   }
1938
1939   /**
1940    * Synonym for {@link #maxItems(Long)}.
1941    *
1942    * @param value
1943    *    The new value for this property.
1944    * @return This object (for method chaining).
1945    */
1946   public HttpPartSchemaBuilder maxi(Long value) {
1947      return maxItems(value);
1948   }
1949
1950   /**
1951    * <mk>maxItems</mk> field.
1952    *
1953    * <p>
1954    * Same as {@link #maxItems(Long)} but takes in a string number.
1955    *
1956    * @param value
1957    *    The new value for this property.
1958    *    <br>Ignored if value is <jk>null</jk> or empty.
1959    * @return This object (for method chaining).
1960    */
1961   public HttpPartSchemaBuilder maxItems(String value) {
1962      maxItems = resolve(value, maxItems);
1963      return this;
1964   }
1965
1966   /**
1967    * Synonym for {@link #maxItems(String)}.
1968    *
1969    * @param value
1970    *    The new value for this property.
1971    * @return This object (for method chaining).
1972    */
1973   public HttpPartSchemaBuilder maxi(String value) {
1974      return maxItems(value);
1975   }
1976
1977   /**
1978    * <mk>minItems</mk> field.
1979    *
1980    * <p>
1981    * An array or collection is valid if its size is greater than, or equal to, the value of this keyword.
1982    *
1983    * <p>
1984    * Only allowed for the following types: <js>"array"</js>.
1985    *
1986    * <p>
1987    * Applicable to the following Swagger schema objects:
1988    * <ul>
1989    *    <li>{@doc ExtSwaggerParameterObject Parameter}
1990    *    <li>{@doc ExtSwaggerSchemaObject Schema}
1991    *    <li>{@doc ExtSwaggerItemsObject Items}
1992    *    <li>{@doc ExtSwaggerHeaderObject Header}
1993    * </ul>
1994    *
1995    * @param value
1996    *    The new value for this property.
1997    *    <br>Ignored if value is <jk>null</jk> or <c>-1</c>.
1998    * @return This object (for method chaining).
1999    */
2000   public HttpPartSchemaBuilder minItems(Long value) {
2001      minItems = resolve(value, minItems);
2002      return this;
2003   }
2004
2005   /**
2006    * Synonym for {@link #minItems(Long)}.
2007    *
2008    * @param value
2009    *    The new value for this property.
2010    * @return This object (for method chaining).
2011    */
2012   public HttpPartSchemaBuilder mini(Long value) {
2013      return minItems(value);
2014   }
2015
2016   /**
2017    * <mk>minItems</mk> field.
2018    *
2019    * <p>
2020    * Same as {@link #minItems(Long)} but takes in a string number.
2021    *
2022    * @param value
2023    *    The new value for this property.
2024    *    <br>Ignored if value is <jk>null</jk> or empty.
2025    * @return This object (for method chaining).
2026    */
2027   public HttpPartSchemaBuilder minItems(String value) {
2028      minItems = resolve(value, minItems);
2029      return this;
2030   }
2031
2032   /**
2033    * Synonym for {@link #minItems(String)}.
2034    *
2035    * @param value
2036    *    The new value for this property.
2037    * @return This object (for method chaining).
2038    */
2039   public HttpPartSchemaBuilder mini(String value) {
2040      return minItems(value);
2041   }
2042
2043   /**
2044    * <mk>uniqueItems</mk> field.
2045    *
2046    * <p>
2047    * If <jk>true</jk>, the input validates successfully if all of its elements are unique.
2048    *
2049    * <p>
2050    * <br>If the parameter type is a subclass of {@link Set}, this validation is skipped (since a set can only contain unique items anyway).
2051    * <br>Otherwise, the collection or array is checked for duplicate items.
2052    *
2053    * <p>
2054    * Only allowed for the following types: <js>"array"</js>.
2055    *
2056    * <p>
2057    * Applicable to the following Swagger schema objects:
2058    * <ul>
2059    *    <li>{@doc ExtSwaggerParameterObject Parameter}
2060    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2061    *    <li>{@doc ExtSwaggerItemsObject Items}
2062    *    <li>{@doc ExtSwaggerHeaderObject Header}
2063    * </ul>
2064    *
2065    * @param value
2066    *    The new value for this property.
2067    *    <br>Ignored if value is <jk>null</jk>.
2068    * @return This object (for method chaining).
2069    */
2070   public HttpPartSchemaBuilder uniqueItems(Boolean value) {
2071      uniqueItems = resolve(value, uniqueItems);
2072      return this;
2073   }
2074
2075   /**
2076    * Synonym for {@link #uniqueItems(Boolean)}.
2077    *
2078    * @param value
2079    *    The new value for this property.
2080    * @return This object (for method chaining).
2081    */
2082   public HttpPartSchemaBuilder ui(Boolean value) {
2083      return uniqueItems(value);
2084   }
2085
2086   /**
2087    * <mk>uniqueItems</mk> field.
2088    *
2089    * <p>
2090    * Same as {@link #uniqueItems(Boolean)} but takes in a string boolean.
2091    *
2092    * @param value
2093    *    The new value for this property.
2094    *    <br>Ignored if value is <jk>null</jk> or empty..
2095    * @return This object (for method chaining).
2096    */
2097   public HttpPartSchemaBuilder uniqueItems(String value) {
2098      uniqueItems = resolve(value, uniqueItems);
2099      return this;
2100   }
2101
2102   /**
2103    * Synonym for {@link #uniqueItems(String)}.
2104    *
2105    * @param value
2106    *    The new value for this property.
2107    * @return This object (for method chaining).
2108    */
2109   public HttpPartSchemaBuilder ui(String value) {
2110      return uniqueItems(value);
2111   }
2112
2113   /**
2114    * <mk>uniqueItems</mk> field.
2115    *
2116    * <p>
2117    * Shortcut for calling <code>uniqueItems(<jk>true</jk>);</code>.
2118    *
2119    * @return This object (for method chaining).
2120    */
2121   public HttpPartSchemaBuilder uniqueItems() {
2122      return uniqueItems(true);
2123   }
2124
2125   /**
2126    * Synonym for {@link #uniqueItems()}.
2127    *
2128    * @return This object (for method chaining).
2129    */
2130   public HttpPartSchemaBuilder ui() {
2131      return uniqueItems();
2132   }
2133
2134   /**
2135    * <mk>skipIfEmpty</mk> field.
2136    *
2137    * <p>
2138    * Identifies whether an item should be skipped during serialization if it's empty.
2139    *
2140    * @param value
2141    *    The new value for this property.
2142    *    <br>Ignored if value is <jk>null</jk>.
2143    * @return This object (for method chaining).
2144    */
2145   public HttpPartSchemaBuilder skipIfEmpty(Boolean value) {
2146      skipIfEmpty = resolve(value, skipIfEmpty);
2147      return this;
2148   }
2149
2150   /**
2151    * Synonym for {@link #skipIfEmpty(Boolean)}.
2152    *
2153    * @param value
2154    *    The new value for this property.
2155    * @return This object (for method chaining).
2156    */
2157   public HttpPartSchemaBuilder sie(Boolean value) {
2158      return skipIfEmpty(value);
2159   }
2160
2161   /**
2162    * <mk>skipIfEmpty</mk> field.
2163    *
2164    * <p>
2165    * Same as {@link #skipIfEmpty(Boolean)} but takes in a string boolean.
2166    *
2167    * @param value
2168    *    The new value for this property.
2169    *    <br>Ignored if value is <jk>null</jk> or empty.
2170    * @return This object (for method chaining).
2171    */
2172   public HttpPartSchemaBuilder skipIfEmpty(String value) {
2173      skipIfEmpty = resolve(value, skipIfEmpty);
2174      return this;
2175   }
2176
2177   /**
2178    * Synonym for {@link #skipIfEmpty(String)}.
2179    *
2180    * @param value
2181    *    The new value for this property.
2182    * @return This object (for method chaining).
2183    */
2184   public HttpPartSchemaBuilder sie(String value) {
2185      return skipIfEmpty(value);
2186   }
2187
2188   /**
2189    * Identifies whether an item should be skipped if it's empty.
2190    *
2191    * <p>
2192    * Shortcut for calling <code>skipIfEmpty(<jk>true</jk>);</code>.
2193    *
2194    * @return This object (for method chaining).
2195    */
2196   public HttpPartSchemaBuilder skipIfEmpty() {
2197      return skipIfEmpty(true);
2198   }
2199
2200   /**
2201    * Synonym for {@link #skipIfEmpty()}.
2202    *
2203    * @return This object (for method chaining).
2204    */
2205   public HttpPartSchemaBuilder sie() {
2206      return skipIfEmpty();
2207   }
2208
2209   /**
2210    * <mk>enum</mk> field.
2211    *
2212    * <p>
2213    * If specified, the input validates successfully if it is equal to one of the elements in this array.
2214    *
2215    * <p>
2216    * Applicable to the following Swagger schema objects:
2217    * <ul>
2218    *    <li>{@doc ExtSwaggerParameterObject Parameter}
2219    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2220    *    <li>{@doc ExtSwaggerItemsObject Items}
2221    *    <li>{@doc ExtSwaggerHeaderObject Header}
2222    * </ul>
2223    *
2224    * @param value
2225    *    The new value for this property.
2226    *    <br>Ignored if value is <jk>null</jk> or an empty set.
2227    * @return This object (for method chaining).
2228    */
2229   public HttpPartSchemaBuilder _enum(Set<String> value) {
2230      if (value != null && ! value.isEmpty())
2231         this._enum = value;
2232      return this;
2233   }
2234
2235   /**
2236    * Synonym for {@link #_enum(Set)}.
2237    *
2238    * @param value
2239    *    The new value for this property.
2240    * @return This object (for method chaining).
2241    */
2242   public HttpPartSchemaBuilder e(Set<String> value) {
2243      return _enum(value);
2244   }
2245
2246   /**
2247    * <mk>_enum</mk> field.
2248    *
2249    * <p>
2250    * Same as {@link #_enum(Set)} but takes in a var-args array.
2251    *
2252    * @param values
2253    *    The new values for this property.
2254    *    <br>Ignored if value is empty.
2255    * @return This object (for method chaining).
2256    */
2257   public HttpPartSchemaBuilder _enum(String...values) {
2258      return _enum(ASet.of(values));
2259   }
2260
2261   /**
2262    * Synonym for {@link #_enum(String...)}.
2263    *
2264    * @param values
2265    *    The new values for this property.
2266    * @return This object (for method chaining).
2267    */
2268   public HttpPartSchemaBuilder e(String...values) {
2269      return _enum(values);
2270   }
2271
2272   /**
2273    * <mk>multipleOf</mk> field.
2274    *
2275    * <p>
2276    * A numeric instance is valid if the result of the division of the instance by this keyword's value is an integer.
2277    *
2278    * <p>
2279    * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>.
2280    *
2281    * <p>
2282    * Applicable to the following Swagger schema objects:
2283    * <ul>
2284    *    <li>{@doc ExtSwaggerParameterObject Parameter}
2285    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2286    *    <li>{@doc ExtSwaggerItemsObject Items}
2287    *    <li>{@doc ExtSwaggerHeaderObject Header}
2288    * </ul>
2289    *
2290    * @param value
2291    *    The new value for this property.
2292    *    <br>Ignored if value is <jk>null</jk>.
2293    * @return This object (for method chaining).
2294    */
2295   public HttpPartSchemaBuilder multipleOf(Number value) {
2296      if (value != null)
2297         this.multipleOf = value;
2298      return this;
2299   }
2300
2301   /**
2302    * Synonym for {@link #multipleOf(Number)}.
2303    *
2304    * @param value
2305    *    The new value for this property.
2306    * @return This object (for method chaining).
2307    */
2308   public HttpPartSchemaBuilder mo(Number value) {
2309      return multipleOf(value);
2310   }
2311
2312   /**
2313    * <mk>mapProperties</mk> field.
2314    *
2315    * <p>
2316    * Applicable to the following Swagger schema objects:
2317    * <ul>
2318    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2319    * </ul>
2320    *
2321    * @param value
2322    *    The new value for this property.
2323    *    <br>Ignored if value is <jk>null</jk> or <c>-1</c>.
2324    * @return This object (for method chaining).
2325    */
2326   public HttpPartSchemaBuilder maxProperties(Long value) {
2327      maxProperties = resolve(value, maxProperties);
2328      return this;
2329   }
2330
2331   /**
2332    * Synonym for {@link #maxProperties(Long)}.
2333    *
2334    * @param value
2335    *    The new value for this property.
2336    * @return This object (for method chaining).
2337    */
2338   public HttpPartSchemaBuilder maxp(Long value) {
2339      return maxProperties(value);
2340   }
2341
2342   /**
2343    * <mk>mapProperties</mk> field.
2344    *
2345    * <p>
2346    * Same as {@link #maxProperties(Long)} but takes in a string number.
2347    *
2348    * @param value
2349    *    The new value for this property.
2350    *    <br>Ignored if value is <jk>null</jk> or empty.
2351    * @return This object (for method chaining).
2352    */
2353   public HttpPartSchemaBuilder maxProperties(String value) {
2354      maxProperties = resolve(value, maxProperties);
2355      return this;
2356   }
2357
2358   /**
2359    * Synonym for {@link #maxProperties(String)}.
2360    *
2361    * @param value
2362    *    The new value for this property.
2363    * @return This object (for method chaining).
2364    */
2365   public HttpPartSchemaBuilder maxp(String value) {
2366      return maxProperties(value);
2367   }
2368
2369   /**
2370    * <mk>minProperties</mk> field.
2371    *
2372    * <p>
2373    * Applicable to the following Swagger schema objects:
2374    * <ul>
2375    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2376    * </ul>
2377    *
2378    * @param value
2379    *    The new value for this property.
2380    *    <br>Ignored if value is <jk>null</jk>.
2381    * @return This object (for method chaining).
2382    */
2383   public HttpPartSchemaBuilder minProperties(Long value) {
2384      minProperties = resolve(value, minProperties);
2385      return this;
2386   }
2387
2388   /**
2389    * Synonym for {@link #minProperties(Long)}.
2390    *
2391    * @param value
2392    *    The new value for this property.
2393    * @return This object (for method chaining).
2394    */
2395   public HttpPartSchemaBuilder minp(Long value) {
2396      return minProperties(value);
2397   }
2398
2399   /**
2400    * <mk>minProperties</mk> field.
2401    *
2402    * <p>
2403    * Same as {@link #minProperties(Long)} but takes in a string boolean.
2404    *
2405    * @param value
2406    *    The new value for this property.
2407    *    <br>Ignored if value is <jk>null</jk> or empty.
2408    * @return This object (for method chaining).
2409    */
2410   public HttpPartSchemaBuilder minProperties(String value) {
2411      minProperties = resolve(value, minProperties);
2412      return this;
2413   }
2414
2415   /**
2416    * Synonym for {@link #minProperties(String)}.
2417    *
2418    * @param value
2419    *    The new value for this property.
2420    * @return This object (for method chaining).
2421    */
2422   public HttpPartSchemaBuilder minp(String value) {
2423      return minProperties(value);
2424   }
2425
2426   /**
2427    * <mk>properties</mk> field.
2428    *
2429    * <p>
2430    * Applicable to the following Swagger schema objects:
2431    * <ul>
2432    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2433    * </ul>
2434    *
2435    * @param key
2436    * The property name.
2437    * @param value
2438    *    The new value for this property.
2439    *    <br>Ignored if value is <jk>null</jk>.
2440    * @return This object (for method chaining).
2441    */
2442   public HttpPartSchemaBuilder property(String key, HttpPartSchemaBuilder value) {
2443      if ( key != null && value != null) {
2444         if (properties == null)
2445            properties = new LinkedHashMap<>();
2446         properties.put(key, value);
2447      }
2448      return this;
2449   }
2450
2451   /**
2452    * <mk>properties</mk> field.
2453    *
2454    * <p>
2455    * Applicable to the following Swagger schema objects:
2456    * <ul>
2457    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2458    * </ul>
2459    *
2460    * @param key
2461    * The property name.
2462    * @param value
2463    *    The new value for this property.
2464    *    <br>Ignored if value is <jk>null</jk>.
2465    * @return This object (for method chaining).
2466    */
2467   public HttpPartSchemaBuilder property(String key, HttpPartSchema value) {
2468      if ( key != null && value != null) {
2469         if (properties == null)
2470            properties = new LinkedHashMap<>();
2471         properties.put(key, value);
2472      }
2473      return this;
2474   }
2475
2476   /**
2477    * Shortcut for <c>property(key, value)</c>.
2478    *
2479    * <p>
2480    * Applicable to the following Swagger schema objects:
2481    * <ul>
2482    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2483    * </ul>
2484    *
2485    * @param key
2486    * The property name.
2487    * @param value
2488    *    The new value for this property.
2489    *    <br>Ignored if value is <jk>null</jk>.
2490    * @return This object (for method chaining).
2491    */
2492   public HttpPartSchemaBuilder p(String key, HttpPartSchemaBuilder value) {
2493      return property(key, value);
2494   }
2495
2496   /**
2497    * Shortcut for <c>property(key, value)</c>.
2498    *
2499    * <p>
2500    * Applicable to the following Swagger schema objects:
2501    * <ul>
2502    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2503    * </ul>
2504    *
2505    * @param key
2506    * The property name.
2507    * @param value
2508    *    The new value for this property.
2509    *    <br>Ignored if value is <jk>null</jk>.
2510    * @return This object (for method chaining).
2511    */
2512   public HttpPartSchemaBuilder p(String key, HttpPartSchema value) {
2513      return property(key, value);
2514   }
2515
2516   private HttpPartSchemaBuilder properties(OMap value) {
2517      if (value != null && ! value.isEmpty())
2518      for (Map.Entry<String,Object> e : value.entrySet())
2519         property(e.getKey(), HttpPartSchema.create().apply((OMap)e.getValue()));
2520      return this;
2521   }
2522
2523   /**
2524    * <mk>additionalProperties</mk> field.
2525    *
2526    * <p>
2527    * Applicable to the following Swagger schema objects:
2528    * <ul>
2529    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2530    * </ul>
2531    *
2532    * @param value
2533    *    The new value for this property.
2534    *    <br>Ignored if value is <jk>null</jk> or empty.
2535    * @return This object (for method chaining).
2536    */
2537   public HttpPartSchemaBuilder additionalProperties(HttpPartSchemaBuilder value) {
2538      if (value != null)
2539         additionalProperties = value;
2540      return this;
2541   }
2542
2543   /**
2544    * <mk>additionalProperties</mk> field.
2545    *
2546    * <p>
2547    * Applicable to the following Swagger schema objects:
2548    * <ul>
2549    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2550    * </ul>
2551    *
2552    * @param value
2553    *    The new value for this property.
2554    *    <br>Ignored if value is <jk>null</jk> or empty.
2555    * @return This object (for method chaining).
2556    */
2557   public HttpPartSchemaBuilder additionalProperties(HttpPartSchema value) {
2558      if (value != null)
2559         additionalProperties = value;
2560      return this;
2561   }
2562
2563   /**
2564    * Shortcut for <c>additionalProperties(value)</c>
2565    *
2566    * <p>
2567    * Applicable to the following Swagger schema objects:
2568    * <ul>
2569    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2570    * </ul>
2571    *
2572    * @param value
2573    *    The new value for this property.
2574    *    <br>Ignored if value is <jk>null</jk> or empty.
2575    * @return This object (for method chaining).
2576    */
2577   public HttpPartSchemaBuilder ap(HttpPartSchemaBuilder value) {
2578      return additionalProperties(value);
2579   }
2580
2581   /**
2582    * Shortcut for <c>additionalProperties(value)</c>
2583    *
2584    * <p>
2585    * Applicable to the following Swagger schema objects:
2586    * <ul>
2587    *    <li>{@doc ExtSwaggerSchemaObject Schema}
2588    * </ul>
2589    *
2590    * @param value
2591    *    The new value for this property.
2592    *    <br>Ignored if value is <jk>null</jk> or empty.
2593    * @return This object (for method chaining).
2594    */
2595   public HttpPartSchemaBuilder ap(HttpPartSchema value) {
2596      return additionalProperties(value);
2597   }
2598
2599   private HttpPartSchemaBuilder additionalProperties(OMap value) {
2600      if (value != null && ! value.isEmpty())
2601         additionalProperties = HttpPartSchema.create().apply(value);
2602      return this;
2603   }
2604
2605   /**
2606    * Identifies the part serializer to use for serializing this part.
2607    *
2608    * @param value
2609    *    The new value for this property.
2610    *    <br>Ignored if value is <jk>null</jk> or {@link HttpPartSerializer.Null}.
2611    * @return This object (for method chaining).
2612    */
2613   public HttpPartSchemaBuilder serializer(Class<? extends HttpPartSerializer> value) {
2614      if (value != null && value != HttpPartSerializer.Null.class)
2615         serializer = value;
2616      return this;
2617   }
2618
2619   /**
2620    * Identifies the part parser to use for parsing this part.
2621    *
2622    * @param value
2623    *    The new value for this property.
2624    *    <br>Ignored if value is <jk>null</jk> or {@link HttpPartParser.Null}.
2625    * @return This object (for method chaining).
2626    */
2627   public HttpPartSchemaBuilder parser(Class<? extends HttpPartParser> value) {
2628      if (value != null && value != HttpPartParser.Null.class)
2629         parser = value;
2630      return this;
2631   }
2632
2633   /**
2634    * Disables Swagger schema usage validation checking.
2635    *
2636    * @param value Specify <jk>true</jk> to prevent {@link ContextRuntimeException} from being thrown if invalid Swagger usage was detected.
2637    * @return This object (for method chaining).
2638    */
2639   public HttpPartSchemaBuilder noValidate(Boolean value) {
2640      if (value != null)
2641         this.noValidate = value;
2642      return this;
2643   }
2644
2645   /**
2646    * Disables Swagger schema usage validation checking.
2647    *
2648    * <p>
2649    * Shortcut for calling <code>noValidate(<jk>true</jk>);</code>.
2650    *
2651    * @return This object (for method chaining).
2652    */
2653   public HttpPartSchemaBuilder noValidate() {
2654      return noValidate(true);
2655   }
2656
2657   private Boolean resolve(String newValue, Boolean oldValue) {
2658      return isEmpty(newValue) ? oldValue : Boolean.valueOf(newValue);
2659   }
2660
2661   private Boolean resolve(Boolean newValue, Boolean oldValue) {
2662      return newValue == null ? oldValue : newValue;
2663   }
2664
2665   private Long resolve(String newValue, Long oldValue) {
2666      return isEmpty(newValue) ? oldValue : Long.parseLong(newValue);
2667   }
2668
2669   private Long resolve(Long newValue, Long oldValue) {
2670      return (newValue == null || newValue == -1) ? oldValue : newValue;
2671   }
2672
2673   private Set<String> toSet(String[]...s) {
2674      return HttpPartSchema.toSet(s);
2675   }
2676
2677   private Number toNumber(String...s) {
2678      return HttpPartSchema.toNumber(s);
2679   }
2680
2681   private Long firstNmo(Long...l) {
2682      for (Long ll : l)
2683         if (ll != null && ll != -1)
2684            return ll;
2685      return null;
2686   }
2687
2688   private String joinnlOrNull(String[]...s) {
2689      for (String[] ss : s)
2690         if (ss.length > 0)
2691            return joinnl(ss);
2692      return null;
2693   }
2694}