001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.dto.swagger; 014 015import static org.apache.juneau.internal.BeanPropertyUtils.*; 016import static org.apache.juneau.internal.ArrayUtils.*; 017 018import java.util.*; 019 020import org.apache.juneau.*; 021import org.apache.juneau.annotation.*; 022import org.apache.juneau.json.*; 023 024/** 025 * A limited subset of JSON-Schema's items object. It is used by parameter definitions that are not located in "body". 026 * 027 * <h5 class='section'>Example:</h5> 028 * <p class='bcode'> 029 * <jc>// Construct using SwaggerBuilder.</jc> 030 * Items x = <jsm>items</jsm>(<js>"string"</js>).minLength(2); 031 * 032 * <jc>// Serialize using JsonSerializer.</jc> 033 * String json = JsonSerializer.<jsf>DEFAULT</jsf>.toString(x); 034 * 035 * <jc>// Or just use toString() which does the same as above.</jc> 036 * String json = x.toString(); 037 * </p> 038 * <p class='bcode'> 039 * <jc>// Output</jc> 040 * { 041 * <js>"type"</js>: <js>"string"</js>, 042 * <js>"minLength"</js>: 2 043 * } 044 * </p> 045 * 046 * <h5 class='section'>See Also:</h5> 047 * <ul class='doctree'> 048 * <li class='link'><a class='doclink' href='../../../../../overview-summary.html#juneau-dto.Swagger'>Overview > juneau-dto > Swagger</a> 049 * </ul> 050 */ 051@Bean(properties="type,format,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf,*") 052public class Items extends SwaggerElement { 053 054 private static final String[] VALID_TYPES = {"string", "number", "integer", "boolean", "array"}; 055 private static final String[] VALID_COLLECTION_FORMATS = {"csv","ssv","tsv","pipes","multi"}; 056 057 private String 058 type, 059 format, 060 collectionFormat, 061 pattern; 062 private Number 063 maximum, 064 minimum, 065 multipleOf; 066 private Integer 067 maxLength, 068 minLength, 069 maxItems, 070 minItems; 071 private Boolean 072 exclusiveMaximum, 073 exclusiveMinimum, 074 uniqueItems; 075 private Items items; 076 private Object _default; 077 private List<Object> _enum; 078 079 @Override /* SwaggerElement */ 080 protected Items strict() { 081 super.strict(); 082 return this; 083 } 084 085 /** 086 * Bean property getter: <property>type</property>. 087 * 088 * <p> 089 * The internal type of the array. 090 * 091 * @return The property value, or <jk>null</jk> if it is not set. 092 */ 093 public String getType() { 094 return type; 095 } 096 097 /** 098 * Bean property setter: <property>type</property>. 099 * 100 * <p> 101 * The internal type of the array. 102 * 103 * @param value 104 * The new value for this property. 105 * <br>Valid values: 106 * <ul> 107 * <li><js>"string"</js> 108 * <li><js>"number"</js> 109 * <li><js>"integer"</js> 110 * <li><js>"boolean"</js> 111 * <li><js>"array"</js> 112 * </ul> 113 * <br>Property value is required. 114 * @return This object (for method chaining). 115 */ 116 public Items setType(String value) { 117 if (isStrict() && ! contains(value, VALID_TYPES)) 118 throw new RuntimeException( 119 "Invalid value passed in to setType(String). Value='"+value+"', valid values=" 120 + JsonSerializer.DEFAULT_LAX.toString(VALID_TYPES)); 121 type = value; 122 return this; 123 } 124 125 /** 126 * Same as {@link #setType(String)}. 127 * 128 * @param value 129 * The new value for this property. 130 * <br>Non-String values will be converted to String using <code>toString()</code>. 131 * <br>Valid values: 132 * <ul> 133 * <li><js>"string"</js> 134 * <li><js>"number"</js> 135 * <li><js>"integer"</js> 136 * <li><js>"boolean"</js> 137 * <li><js>"array"</js> 138 * </ul> 139 * <br>Can be <jk>null</jk> to unset the property. 140 * @return This object (for method chaining). 141 */ 142 public Items type(Object value) { 143 return setType(toStringVal(value)); 144 } 145 146 /** 147 * Bean property getter: <property>format</property>. 148 * 149 * <p> 150 * The extending format for the previously mentioned <code>type</code>. 151 * 152 * <h5 class='section'>See Also:</h5> 153 * <ul> 154 * <li class='extlink'><a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a> 155 * </ul> 156 * 157 * @return The property value, or <jk>null</jk> if it is not set. 158 */ 159 public String getFormat() { 160 return format; 161 } 162 163 /** 164 * Bean property setter: <property>format</property>. 165 * 166 * <p> 167 * The extending format for the previously mentioned <code>type</code>. 168 * 169 * <h5 class='section'>See Also:</h5> 170 * <ul> 171 * <li class='extlink'><a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a> 172 * </ul> 173 * 174 * @param value 175 * The new value for this property. 176 * <br>Can be <jk>null</jk> to unset the property. 177 * @return This object (for method chaining). 178 */ 179 public Items setFormat(String value) { 180 format = value; 181 return this; 182 } 183 184 /** 185 * Same as {@link #setFormat(String)}. 186 * 187 * @param value 188 * The new value for this property. 189 * <br>Non-String values will be converted to String using <code>toString()</code>. 190 * <br>Can be <jk>null</jk> to unset the property. 191 * @return This object (for method chaining). 192 */ 193 public Items format(Object value) { 194 return setFormat(toStringVal(value)); 195 } 196 197 /** 198 * Bean property getter: <property>items</property>. 199 * 200 * <p> 201 * Describes the type of items in the array. 202 * 203 * @return The property value, or <jk>null</jk> if it is not set. 204 */ 205 public Items getItems() { 206 return items; 207 } 208 209 /** 210 * Bean property setter: <property>items</property>. 211 * 212 * <p> 213 * Describes the type of items in the array. 214 * 215 * @param value 216 * The new value for this property. 217 * <br>Property value is required if <code>type</code> is <js>"array"</js>. 218 * <br>Can be <jk>null</jk> to unset the property. 219 * @return This object (for method chaining). 220 */ 221 public Items setItems(Items value) { 222 items = value; 223 return this; 224 } 225 226 /** 227 * Same as {@link #setItems(Items)}. 228 * 229 * @param value 230 * The new value for this property. 231 * <br>Property value is required if <code>type</code> is <js>"array"</js>. 232 * <br>Valid types: 233 * <ul> 234 * <li>{@link Items} 235 * <li><code>String</code> - JSON object representation of {@link Items} 236 * <h5 class='figure'>Example:</h5> 237 * <p class='bcode'> 238 * items(<js>"{type:'type',format:'format',...}"</js>); 239 * </p> 240 * </ul> 241 * <br>Can be <jk>null</jk> to unset the property. 242 * @return This object (for method chaining). 243 */ 244 public Items items(Object value) { 245 return setItems(toType(value, Items.class)); 246 } 247 248 /** 249 * Bean property getter: <property>collectionFormat</property>. 250 * 251 * <p> 252 * Determines the format of the array if type array is used. 253 * 254 * @return The property value, or <jk>null</jk> if it is not set. 255 */ 256 public String getCollectionFormat() { 257 return collectionFormat; 258 } 259 260 /** 261 * Bean property setter: <property>collectionFormat</property>. 262 * 263 * <p> 264 * Determines the format of the array if type array is used. 265 * 266 * @param value 267 * The new value for this property. 268 * <br>Valid values: 269 * <ul> 270 * <li><js>"csv"</js> (default) - comma separated values <code>foo,bar</code>. 271 * <li><js>"ssv"</js> - space separated values <code>foo bar</code>. 272 * <li><js>"tsv"</js> - tab separated values <code>foo\tbar</code>. 273 * <li><js>"pipes"</js> - pipe separated values <code>foo|bar</code>. 274 * </ul> 275 * <br>Can be <jk>null</jk> to unset the property. 276 * @return This object (for method chaining). 277 */ 278 public Items setCollectionFormat(String value) { 279 if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS)) 280 throw new FormattedRuntimeException( 281 "Invalid value passed in to setCollectionFormat(String). Value=''{0}'', valid values={1}", 282 value, VALID_COLLECTION_FORMATS 283 ); 284 collectionFormat = value; 285 return this; 286 } 287 288 /** 289 * Same as {@link #setCollectionFormat(String)}. 290 * 291 * @param value 292 * The new value for this property. 293 * <br>Non-String values will be converted to String using <code>toString()</code>. 294 * <br>Valid values: 295 * <ul> 296 * <li><js>"csv"</js> (default) - comma separated values <code>foo,bar</code>. 297 * <li><js>"ssv"</js> - space separated values <code>foo bar</code>. 298 * <li><js>"tsv"</js> - tab separated values <code>foo\tbar</code>. 299 * <li><js>"pipes"</js> - pipe separated values <code>foo|bar</code>. 300 * </ul> 301 * <br>Can be <jk>null</jk> to unset the property. 302 * @return This object (for method chaining). 303 */ 304 public Items collectionFormat(Object value) { 305 return setCollectionFormat(toStringVal(value)); 306 } 307 308 /** 309 * Bean property getter: <property>default</property>. 310 * 311 * <p> 312 * Declares the value of the item that the server will use if none is provided. 313 * 314 * <h5 class='section'>Notes:</h5> 315 * <ul class='spaced-list'> 316 * <li> 317 * <js>"default"</js> has no meaning for required items. 318 * <li> 319 * Unlike JSON Schema this value MUST conform to the defined <code>type</code> for the data type. 320 * </ul> 321 * 322 * <h5 class='section'>See Also:</h5> 323 * <ul> 324 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor101">http://json-schema.org/latest/json-schema-validation.html#anchor101</a> 325 * </ul> 326 * 327 * @return The property value, or <jk>null</jk> if it is not set. 328 */ 329 public Object getDefault() { 330 return _default; 331 } 332 333 /** 334 * Bean property setter: <property>default</property>. 335 * 336 * <p> 337 * Declares the value of the item that the server will use if none is provided. 338 * 339 * <h5 class='section'>Notes:</h5> 340 * <ul class='spaced-list'> 341 * <li> 342 * <js>"default"</js> has no meaning for required items. 343 * <li> 344 * Unlike JSON Schema this value MUST conform to the defined <code>type</code> for the data type. 345 * </ul> 346 * 347 * <h5 class='section'>See Also:</h5> 348 * <ul> 349 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor101">http://json-schema.org/latest/json-schema-validation.html#anchor101</a> 350 * </ul> 351 * 352 * @param value 353 * The new value for this property. 354 * <br>Can be <jk>null</jk> to unset the property. 355 * @return This object (for method chaining). 356 */ 357 public Items setDefault(Object value) { 358 _default = value; 359 return this; 360 } 361 362 /** 363 * Same as {@link #setDefault(Object)}. 364 * 365 * @param value 366 * The new value for this property. 367 * <br>Can be <jk>null</jk> to unset the property. 368 * @return This object (for method chaining). 369 */ 370 public Items _default(Object value) { 371 return setDefault(value); 372 } 373 374 /** 375 * Bean property getter: <property>maximum</property>. 376 * 377 * <h5 class='section'>See Also:</h5> 378 * <ul> 379 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17">http://json-schema.org/latest/json-schema-validation.html#anchor17</a> 380 * </ul> 381 * 382 * @return The property value, or <jk>null</jk> if it is not set. 383 */ 384 public Number getMaximum() { 385 return maximum; 386 } 387 388 /** 389 * Bean property setter: <property>maximum</property>. 390 * 391 * <h5 class='section'>See Also:</h5> 392 * <ul> 393 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17">http://json-schema.org/latest/json-schema-validation.html#anchor17</a> 394 * </ul> 395 * 396 * @param value 397 * The new value for this property. 398 * <br>Can be <jk>null</jk> to unset the property. 399 * @return This object (for method chaining). 400 */ 401 public Items setMaximum(Number value) { 402 maximum = value; 403 return this; 404 } 405 406 /** 407 * Same as {@link #setMaximum(Number)}. 408 * 409 * @param value 410 * The new value for this property. 411 * <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match. 412 * <br>Can be <jk>null</jk> to unset the property. 413 * @return This object (for method chaining). 414 */ 415 public Items maximum(Object value) { 416 return setMaximum(toNumber(value)); 417 } 418 419 /** 420 * Bean property getter: <property>exclusiveMaximum</property>. 421 * 422 * <h5 class='section'>See Also:</h5> 423 * <ul> 424 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17">http://json-schema.org/latest/json-schema-validation.html#anchor17</a> 425 * </ul> 426 * 427 * @return The property value, or <jk>null</jk> if it is not set. 428 */ 429 public Boolean getExclusiveMaximum() { 430 return exclusiveMaximum; 431 } 432 433 /** 434 * Bean property setter: <property>exclusiveMaximum</property>. 435 * 436 * <h5 class='section'>See Also:</h5> 437 * <ul> 438 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17">http://json-schema.org/latest/json-schema-validation.html#anchor17</a> 439 * </ul> 440 * 441 * @param value 442 * The new value for this property. 443 * <br>Can be <jk>null</jk> to unset the property. 444 * @return This object (for method chaining). 445 */ 446 public Items setExclusiveMaximum(Boolean value) { 447 exclusiveMaximum = value; 448 return this; 449 } 450 451 /** 452 * Same as {@link #setExclusiveMaximum(Boolean)}. 453 * 454 * @param value 455 * The new value for this property. 456 * <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>. 457 * <br>Can be <jk>null</jk> to unset the property. 458 * @return This object (for method chaining). 459 */ 460 public Items exclusiveMaximum(Object value) { 461 return setExclusiveMaximum(toBoolean(value)); 462 } 463 464 /** 465 * Bean property getter: <property>minimum</property>. 466 * 467 * <h5 class='section'>See Also:</h5> 468 * <ul> 469 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21">http://json-schema.org/latest/json-schema-validation.html#anchor21</a> 470 * </ul> 471 * 472 * @return The property value, or <jk>null</jk> if it is not set. 473 */ 474 public Number getMinimum() { 475 return minimum; 476 } 477 478 /** 479 * Bean property setter: <property>minimum</property>. 480 * 481 * <h5 class='section'>See Also:</h5> 482 * <ul> 483 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21">http://json-schema.org/latest/json-schema-validation.html#anchor21</a> 484 * </ul> 485 * 486 * @param value 487 * The new value for this property. 488 * <br>Can be <jk>null</jk> to unset the property. 489 * @return This object (for method chaining). 490 */ 491 public Items setMinimum(Number value) { 492 minimum = value; 493 return this; 494 } 495 496 /** 497 * Same as {@link #setMinimum(Number)}. 498 * 499 * @param value 500 * The new value for this property. 501 * <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match. 502 * <br>Can be <jk>null</jk> to unset the property. 503 * @return This object (for method chaining). 504 */ 505 public Items minimum(Object value) { 506 return setMinimum(toNumber(value)); 507 } 508 509 /** 510 * Bean property getter: <property>exclusiveMinimum</property>. 511 * 512 * <h5 class='section'>See Also:</h5> 513 * <ul> 514 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21">http://json-schema.org/latest/json-schema-validation.html#anchor21</a> 515 * </ul> 516 * 517 * @return The property value, or <jk>null</jk> if it is not set. 518 */ 519 public Boolean getExclusiveMinimum() { 520 return exclusiveMinimum; 521 } 522 523 /** 524 * Bean property setter: <property>exclusiveMinimum</property>. 525 * 526 * <h5 class='section'>See Also:</h5> 527 * <ul> 528 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21">http://json-schema.org/latest/json-schema-validation.html#anchor21</a> 529 * </ul> 530 * 531 * @param value 532 * The new value for this property. 533 * <br>Can be <jk>null</jk> to unset the property. 534 * @return This object (for method chaining). 535 */ 536 public Items setExclusiveMinimum(Boolean value) { 537 exclusiveMinimum = value; 538 return this; 539 } 540 541 /** 542 * Same as {@link #setExclusiveMinimum(Boolean)}. 543 * 544 * @param value 545 * The new value for this property. 546 * <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>. 547 * <br>Can be <jk>null</jk> to unset the property. 548 * @return This object (for method chaining). 549 */ 550 public Items exclusiveMinimum(Object value) { 551 return setExclusiveMinimum(toBoolean(value)); 552 } 553 554 /** 555 * Bean property getter: <property>maxLength</property>. 556 * 557 * <h5 class='section'>See Also:</h5> 558 * <ul> 559 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor26">http://json-schema.org/latest/json-schema-validation.html#anchor26</a> 560 * </ul> 561 * 562 * @return The property value, or <jk>null</jk> if it is not set. 563 */ 564 public Integer getMaxLength() { 565 return maxLength; 566 } 567 568 /** 569 * Bean property setter: <property>maxLength</property>. 570 * 571 * <h5 class='section'>See Also:</h5> 572 * <ul> 573 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor26">http://json-schema.org/latest/json-schema-validation.html#anchor26</a> 574 * </ul> 575 * 576 * @param value 577 * The new value for this property. 578 * <br>Can be <jk>null</jk> to unset the property. 579 * @return This object (for method chaining). 580 */ 581 public Items setMaxLength(Integer value) { 582 maxLength = value; 583 return this; 584 } 585 586 /** 587 * Same as {@link #setMaxLength(Integer)}. 588 * 589 * @param value 590 * The new value for this property. 591 * <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>. 592 * <br>Can be <jk>null</jk> to unset the property. 593 * @return This object (for method chaining). 594 */ 595 public Items maxLength(Object value) { 596 return setMaxLength(toInteger(value)); 597 } 598 599 /** 600 * Bean property getter: <property>minLength</property>. 601 * 602 * <h5 class='section'>See Also:</h5> 603 * <ul> 604 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor29">http://json-schema.org/latest/json-schema-validation.html#anchor29</a> 605 * </ul> 606 * 607 * @return The property value, or <jk>null</jk> if it is not set. 608 */ 609 public Integer getMinLength() { 610 return minLength; 611 } 612 613 /** 614 * Bean property setter: <property>minLength</property>. 615 * 616 * <h5 class='section'>See Also:</h5> 617 * <ul> 618 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor29">http://json-schema.org/latest/json-schema-validation.html#anchor29</a> 619 * </ul> 620 * 621 * @param value 622 * The new value for this property. 623 * <br>Can be <jk>null</jk> to unset the property. 624 * @return This object (for method chaining). 625 */ 626 public Items setMinLength(Integer value) { 627 minLength = value; 628 return this; 629 } 630 631 /** 632 * Same as {@link #setMinLength(Integer)}. 633 * 634 * @param value 635 * The new value for this property. 636 * <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>. 637 * <br>Can be <jk>null</jk> to unset the property. 638 * @return This object (for method chaining). 639 */ 640 public Items minLength(Object value) { 641 return setMinLength(toInteger(value)); 642 } 643 644 /** 645 * Bean property getter: <property>pattern</property>. 646 * 647 * <h5 class='section'>See Also:</h5> 648 * <ul> 649 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor33">http://json-schema.org/latest/json-schema-validation.html#anchor33</a> 650 * </ul> 651 * 652 * @return The property value, or <jk>null</jk> if it is not set. 653 */ 654 public String getPattern() { 655 return pattern; 656 } 657 658 /** 659 * Bean property setter: <property>pattern</property>. 660 * 661 * <h5 class='section'>See Also:</h5> 662 * <ul> 663 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor33">http://json-schema.org/latest/json-schema-validation.html#anchor33</a> 664 * </ul> 665 * 666 * @param value 667 * The new value for this property. 668 * <br>Can be <jk>null</jk> to unset the property. 669 * @return This object (for method chaining). 670 */ 671 public Items setPattern(String value) { 672 pattern = value; 673 return this; 674 } 675 676 /** 677 * Same as {@link #setPattern(String)}. 678 * 679 * @param value 680 * The new value for this property. 681 * <br>Non-String values will be converted to String using <code>toString()</code>. 682 * <br>Can be <jk>null</jk> to unset the property. 683 * @return This object (for method chaining). 684 */ 685 public Items pattern(Object value) { 686 return setPattern(toStringVal(value)); 687 } 688 689 /** 690 * Bean property getter: <property>maxItems</property>. 691 * 692 * <h5 class='section'>See Also:</h5> 693 * <ul> 694 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor42">http://json-schema.org/latest/json-schema-validation.html#anchor42</a> 695 * </ul> 696 * 697 * @return The property value, or <jk>null</jk> if it is not set. 698 */ 699 public Integer getMaxItems() { 700 return maxItems; 701 } 702 703 /** 704 * Bean property setter: <property>maxItems</property>. 705 * 706 * <h5 class='section'>See Also:</h5> 707 * <ul> 708 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor42">http://json-schema.org/latest/json-schema-validation.html#anchor42</a> 709 * </ul> 710 * 711 * @param value 712 * The new value for this property. 713 * <br>Can be <jk>null</jk> to unset the property. 714 * @return This object (for method chaining). 715 */ 716 public Items setMaxItems(Integer value) { 717 maxItems = value; 718 return this; 719 } 720 721 /** 722 * Same as {@link #setMaxItems(Integer)}. 723 * 724 * @param value 725 * The new value for this property. 726 * <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>. 727 * <br>Can be <jk>null</jk> to unset the property. 728 * @return This object (for method chaining). 729 */ 730 public Items maxItems(Object value) { 731 return setMaxItems(toInteger(value)); 732 } 733 734 /** 735 * Bean property getter: <property>minItems</property>. 736 * 737 * <h5 class='section'>See Also:</h5> 738 * <ul> 739 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor45">http://json-schema.org/latest/json-schema-validation.html#anchor45</a> 740 * </ul> 741 * 742 * @return The property value, or <jk>null</jk> if it is not set. 743 */ 744 public Integer getMinItems() { 745 return minItems; 746 } 747 748 /** 749 * Bean property setter: <property>minItems</property>. 750 * 751 * <h5 class='section'>See Also:</h5> 752 * <ul> 753 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor45">http://json-schema.org/latest/json-schema-validation.html#anchor45</a> 754 * </ul> 755 * 756 * @param value 757 * The new value for this property. 758 * <br>Can be <jk>null</jk> to unset the property. 759 * @return This object (for method chaining). 760 */ 761 public Items setMinItems(Integer value) { 762 minItems = value; 763 return this; 764 } 765 766 /** 767 * Same as {@link #setMinItems(Integer)}. 768 * 769 * @param value 770 * The new value for this property. 771 * <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>. 772 * <br>Can be <jk>null</jk> to unset the property. 773 * @return This object (for method chaining). 774 */ 775 public Items minItems(Object value) { 776 return setMinItems(toInteger(value)); 777 } 778 779 /** 780 * Bean property getter: <property>uniqueItems</property>. 781 * 782 * <h5 class='section'>See Also:</h5> 783 * <ul> 784 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor49">http://json-schema.org/latest/json-schema-validation.html#anchor49</a> 785 * </ul> 786 * 787 * @return The property value, or <jk>null</jk> if it is not set. 788 */ 789 public Boolean getUniqueItems() { 790 return uniqueItems; 791 } 792 793 /** 794 * Bean property setter: <property>uniqueItems</property>. 795 * 796 * <h5 class='section'>See Also:</h5> 797 * <ul> 798 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor49">http://json-schema.org/latest/json-schema-validation.html#anchor49</a> 799 * </ul> 800 * 801 * @param value 802 * The new value for this property. 803 * <br>Can be <jk>null</jk> to unset the property. 804 * @return This object (for method chaining). 805 */ 806 public Items setUniqueItems(Boolean value) { 807 uniqueItems = value; 808 return this; 809 } 810 811 /** 812 * Same as {@link #setUniqueItems(Boolean)}. 813 * 814 * @param value 815 * The new value for this property. 816 * <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>. 817 * <br>Can be <jk>null</jk> to unset the property. 818 * @return This object (for method chaining). 819 */ 820 public Items uniqueItems(Object value) { 821 return setUniqueItems(toBoolean(value)); 822 } 823 824 /** 825 * Bean property getter: <property>enum</property>. 826 * 827 * <h5 class='section'>See Also:</h5> 828 * <ul> 829 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76">http://json-schema.org/latest/json-schema-validation.html#anchor76</a> 830 * </ul> 831 * 832 * @return The property value, or <jk>null</jk> if it is not set. 833 */ 834 public List<Object> getEnum() { 835 return _enum; 836 } 837 838 /** 839 * Bean property setter: <property>enum</property>. 840 * 841 * <h5 class='section'>See Also:</h5> 842 * <ul> 843 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76">http://json-schema.org/latest/json-schema-validation.html#anchor76</a> 844 * </ul> 845 * 846 * @param value 847 * The new value for this property. 848 * <br>Can be <jk>null</jk> to unset the property. 849 * @return This object (for method chaining). 850 */ 851 public Items setEnum(Collection<Object> value) { 852 _enum = newList(value); 853 return this; 854 } 855 856 /** 857 * Adds one or more values to the <property>enum</property> property. 858 * 859 * @param values 860 * The values to add to this property. 861 * <br>Ignored if <jk>null</jk>. 862 * @return This object (for method chaining). 863 */ 864 public Items addEnum(Collection<Object> values) { 865 _enum = addToList(_enum, values); 866 return this; 867 } 868 869 /** 870 * Adds one or more values to the <property>enum</property> property. 871 * 872 * @param values 873 * The values to add to this property. 874 * <br>Valid types: 875 * <ul> 876 * <li><code>Object</code> 877 * <li><code>Collection<Object></code> 878 * <li><code>String</code> - JSON array representation of <code>Collection<Object></code> 879 * <h5 class='figure'>Example:</h5> 880 * <p class='bcode'> 881 * _enum(<js>"['foo','bar']"</js>); 882 * </p> 883 * <li><code>String</code> - Individual values 884 * <h5 class='figure'>Example:</h5> 885 * <p class='bcode'> 886 * _enum(<js>"foo"</js>, <js>"bar"</js>); 887 * </p> 888 * </ul> 889 * <br>Ignored if <jk>null</jk>. 890 * @return This object (for method chaining). 891 */ 892 public Items _enum(Object...values) { 893 _enum = addToList(_enum, values, Object.class); 894 return this; 895 } 896 897 /** 898 * Bean property getter: <property>multipleOf</property>. 899 * 900 * <h5 class='section'>See Also:</h5> 901 * <ul> 902 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor14">http://json-schema.org/latest/json-schema-validation.html#anchor14</a> 903 * </ul> 904 * 905 * @return The property value, or <jk>null</jk> if it is not set. 906 */ 907 public Number getMultipleOf() { 908 return multipleOf; 909 } 910 911 /** 912 * Bean property setter: <property>multipleOf</property>. 913 * 914 * <h5 class='section'>See Also:</h5> 915 * <ul> 916 * <li class='extlink'><a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor14">http://json-schema.org/latest/json-schema-validation.html#anchor14</a> 917 * </ul> 918 * 919 * @param value 920 * The new value for this property. 921 * <br>Can be <jk>null</jk> to unset the property. 922 * @return This object (for method chaining). 923 */ 924 public Items setMultipleOf(Number value) { 925 multipleOf = value; 926 return this; 927 } 928 929 /** 930 * Same as {@link #setMultipleOf(Number)}. 931 * 932 * @param value 933 * The new value for this property. 934 * <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match. 935 * <br>Can be <jk>null</jk> to unset the property. 936 * @return This object (for method chaining). 937 */ 938 public Items multipleOf(Object value) { 939 return setMultipleOf(toNumber(value)); 940 } 941 942 @Override /* SwaggerElement */ 943 public <T> T get(String property, Class<T> type) { 944 if (property == null) 945 return null; 946 switch (property) { 947 case "type": return toType(getType(), type); 948 case "format": return toType(getFormat(), type); 949 case "items": return toType(getItems(), type); 950 case "collectionFormat": return toType(getCollectionFormat(), type); 951 case "default": return toType(getDefault(), type); 952 case "maximum": return toType(getMaximum(), type); 953 case "exclusiveMaximum": return toType(getExclusiveMaximum(), type); 954 case "minimum": return toType(getMinimum(), type); 955 case "exclusiveMinimum": return toType(getExclusiveMinimum(), type); 956 case "maxLength": return toType(getMaxLength(), type); 957 case "minLength": return toType(getMinLength(), type); 958 case "pattern": return toType(getPattern(), type); 959 case "maxItems": return toType(getMaxItems(), type); 960 case "minItems": return toType(getMinItems(), type); 961 case "uniqueItems": return toType(getUniqueItems(), type); 962 case "enum": return toType(getEnum(), type); 963 case "multipleOf": return toType(getMultipleOf(), type); 964 default: return super.get(property, type); 965 } 966 } 967 968 @Override /* SwaggerElement */ 969 public Items set(String property, Object value) { 970 if (property == null) 971 return this; 972 switch (property) { 973 case "type": return type(value); 974 case "format": return format(value); 975 case "items": return items(value); 976 case "collectionFormat": return collectionFormat(value); 977 case "default": return _default(value); 978 case "maximum": return maximum(value); 979 case "exclusiveMaximum": return exclusiveMaximum(value); 980 case "minimum": return minimum(value); 981 case "exclusiveMinimum": return exclusiveMinimum(value); 982 case "maxLength": return maxLength(value); 983 case "minLength": return minLength(value); 984 case "pattern": return pattern(value); 985 case "maxItems": return maxItems(value); 986 case "minItems": return minItems(value); 987 case "uniqueItems": return uniqueItems(value); 988 case "enum": return setEnum(null)._enum(value); 989 case "multipleOf": return multipleOf(value); 990 default: 991 super.set(property, value); 992 return this; 993 } 994 } 995}