001/* 002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.test.generator.internal.net.java.quickcheck.generator; 017 018import de.cuioss.test.generator.internal.net.java.quickcheck.ExtendibleGenerator; 019import de.cuioss.test.generator.internal.net.java.quickcheck.FrequencyGenerator; 020import de.cuioss.test.generator.internal.net.java.quickcheck.Generator; 021import de.cuioss.test.generator.internal.net.java.quickcheck.GeneratorException; 022import de.cuioss.test.generator.internal.net.java.quickcheck.StatefulGenerator; 023import de.cuioss.test.generator.internal.net.java.quickcheck.collection.Pair; 024import de.cuioss.test.generator.internal.net.java.quickcheck.collection.Triple; 025import de.cuioss.test.generator.internal.net.java.quickcheck.generator.distribution.Distribution; 026import de.cuioss.test.generator.internal.net.java.quickcheck.generator.support.ByteArrayGenerator; 027import lombok.experimental.UtilityClass; 028 029import java.util.Comparator; 030import java.util.Iterator; 031import java.util.List; 032import java.util.Map; 033import java.util.Set; 034 035/** 036 * {@link CombinedGenerators} can be used to create custom {@link Generator}s. 037 */ 038@UtilityClass 039public class CombinedGenerators { 040 041 public static final int DEFAULT_COLLECTION_MAX_SIZE = Generators.DEFAULT_COLLECTION_MAX_SIZE; 042 // TODO this could be a bit high 043 // for runs = 200 this means 20000 tries for the worst case 044 public static final int DEFAULT_MAX_TRIES = Generators.DEFAULT_MAX_TRIES; 045 046 /** 047 * <p> 048 * Create a frequency generator. The frequency of {@link Generator} usage 049 * depends on the generator weight. 050 * </p> 051 * 052 * @param generator pairs of generators and their weights used to created the 053 * values 054 * @param <T> type of values generated by the generators. 055 */ 056 public static <T> FrequencyGenerator<T> frequency(Generator<T> generator, int weight) { 057 return Generators.frequency(generator, weight); 058 } 059 060 /** 061 * OneOf is a convenience method for 062 * {@link CombinedGenerators#frequency(Generator, int)} when all generator share 063 * the same weight. 064 */ 065 public static <T> ExtendibleGenerator<T, T> oneOf(Generator<T> generator) { 066 return Generators.oneOf(generator); 067 } 068 069 /** 070 * Create a generator which will create vectors (here lists) of type T. 071 * 072 * @param <T> Type of the list values. 073 * @param size Number of element in the vector. 074 */ 075 public static <T> Generator<List<T>> vectors(Generator<T> content, int size) { 076 return Generators.vectors(content, size); 077 } 078 079 /** 080 * Create a generator of pairs of type A for the left value and type B for the 081 * right value. 082 * 083 * @param <A> Type of left value. 084 * @param <B> Type of right value. 085 * @param first Generator for left values. 086 * @param second Generator for right values. 087 */ 088 public static <A, B> Generator<Pair<A, B>> pairs(Generator<A> first, Generator<B> second) { 089 return Generators.pairs(first, second); 090 } 091 092 /** 093 * Create a generator of pairs where first value <= second value. 094 * 095 * @param <T> Type of the pair values. 096 * @param content Generator for content of the pair values. 097 */ 098 public static <T extends Comparable<T>> Generator<Pair<T, T>> sortedPairs(Generator<T> content) { 099 return Generators.sortedPairs(content); 100 } 101 102 /** 103 * Create a generator of triples of the types A, B and C for first, second and 104 * third value. 105 * 106 * @param <A> Type of first value. 107 * @param <B> Type of second value. 108 * @param <C> Type of third value. 109 * @param first Generator for first values. 110 * @param second Generator for second values. 111 * @param third Generator for third values. 112 */ 113 public static <A, B, C> Generator<Triple<A, B, C>> triples(Generator<A> first, Generator<B> second, 114 Generator<C> third) { 115 return Generators.triples(first, second, third); 116 } 117 118 /** 119 * Create a generator return the given values. 120 * 121 * @param <T> Type of the values generated. 122 */ 123 @SafeVarargs 124 public static <T> Generator<T> nullsAnd(T... values) { 125 return Generators.nullsAnd(values); 126 } 127 128 /** 129 * Create a generator of triples where first value <= second value <= 130 * third value. 131 * 132 * @param <T> Type of the triple values. 133 * @param content Generator for content of the triple values. 134 */ 135 public static <T extends Comparable<T>> Generator<Triple<T, T, T>> sortedTriple(Generator<T> content) { 136 return Generators.sortedTriple(content); 137 } 138 139 /** 140 * Create a generator as a combination of a null value generator and generator 141 * of type T. 142 * 143 * @param <T> Type of the values generated. 144 */ 145 public static <T> Generator<T> nullsAnd(Generator<T> generator) { 146 return Generators.nullsAnd(generator); 147 } 148 149 /** 150 * Create a generator as a combination of a null value generator and generator 151 * of type T. 152 * 153 * @param <T> Type of the values generated. 154 * @param weight weight of the provided generator 155 */ 156 public static <T> Generator<T> nullsAnd(Generator<T> generator, int weight) { 157 return Generators.nullsAnd(generator, weight); 158 } 159 160 /** 161 * Create a generator of sets with values from the content generator. 162 * 163 * @param <T> type of set elements generated 164 * @param content generator providing the content of sets generated 165 */ 166 public static <T> Generator<Set<T>> sets(Generator<? extends T> content) { 167 return Generators.sets(content); 168 } 169 170 /** 171 * Create a generator of sets with values from the content generator. 172 * 173 * @param <T> type of set elements generated 174 * @param content generator providing the content of sets generated 175 * @param size size of the sets generated 176 */ 177 public static <T> Generator<Set<T>> sets(Generator<? extends T> content, Generator<Integer> size) { 178 return Generators.sets(content, size); 179 } 180 181 /** 182 * Create a generator of sets with values from the content generator. Length is 183 * between high and low. 184 * 185 * @param <T> type of set elements generated 186 * @param content generator providing the content of sets generated 187 * @param low minimal size 188 * @param high max size 189 */ 190 public static <T> Generator<Set<T>> sets(Generator<? extends T> content, int low, int high) { 191 return Generators.sets(content, low, high); 192 } 193 194 /** 195 * Create a generator of sets that are not empty. 196 * 197 * @param <T> type of set elements generated 198 * @param content generator providing the content of sets generated 199 */ 200 public static <T> Generator<Set<T>> nonEmptySets(Generator<? extends T> content) { 201 return Generators.nonEmptySets(content); 202 } 203 204 @SafeVarargs 205 public static <T> Generator<Set<T>> sets(T... superset) { 206 return Generators.sets(superset); 207 } 208 209 /** 210 * Create a generator of subsets from a given set. 211 * 212 * @param <T> type of set elements generated 213 * @param superset of the generated set 214 */ 215 public static <T> Generator<Set<T>> sets(Iterable<T> superset) { 216 return Generators.sets(superset); 217 } 218 219 /** 220 * Create a generator of subsets from a given set. 221 * 222 * @param <T> type of set elements generated 223 * @param superset of the generated set 224 * @param size of the generated set 225 */ 226 public static <T> Generator<Set<T>> sets(Iterable<T> superset, Generator<Integer> size) { 227 return Generators.sets(superset, size); 228 } 229 230 /** 231 * Create a generator that produces lists of duplicates. 232 * 233 * @return a list derived from the input values. At least one input value is 234 * more than once in the resulting list. 235 */ 236 @SafeVarargs 237 public static <T> Generator<List<T>> duplicates(T... input) { 238 return Generators.duplicates(input); 239 } 240 241 /** 242 * Create a generator that produces lists of duplicates. 243 * 244 * @return a list derived from the input values. At least one input value is 245 * more than once in the resulting list. 246 */ 247 public static <T> Generator<List<T>> duplicates(Iterable<T> input) { 248 return Generators.duplicates(input); 249 } 250 251 /** 252 * Create a generator of iterators. 253 * 254 * <p> 255 * Values of the elements will be taken from the content generator. 256 * </p> 257 * 258 * @param <T> type of iterator elements generated 259 * @param content generator providing the content of iterators generated 260 */ 261 public static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content) { 262 return Generators.iterators(content); 263 } 264 265 /** 266 * Create a generator of iterators. 267 * 268 * <p> 269 * Values of the elements will be taken from the content generator. The 270 * generated iterator will have at least one element. 271 * </p> 272 * 273 * @param <T> type of iterator elements generated 274 * @param content generator providing the content of iterators generated 275 */ 276 public static <T> Generator<Iterator<T>> nonEmptyIterators(Generator<T> content) { 277 return Generators.nonEmptyIterators(content); 278 } 279 280 /** 281 * Create a generator of iterators. 282 * 283 * <p> 284 * Values of the elements will be taken from the content generator. The length 285 * of the iterators will be determined with the size generator. 286 * </p> 287 * 288 * @param <T> type of iterator elements generated 289 * @param content generator providing the content of iterators generated 290 * @param size used to determine the number of elements of the iterator 291 */ 292 public static <T> Generator<Iterator<T>> iterators(Generator<? extends T> content, Generator<Integer> size) { 293 return Generators.iterators(content, size); 294 } 295 296 /** 297 * Create a generator of lists with values from the content generator. Length 298 * values of lists generated will be created with {@link Distribution#UNIFORM}. 299 * 300 * @param <T> type of list elements generated 301 * @param content generator providing the content of lists generated 302 */ 303 public static <T> Generator<List<T>> lists(Generator<? extends T> content) { 304 return Generators.lists(content); 305 } 306 307 /** 308 * Create a generator of non-empty lists with values from the content generator. 309 * Length values of lists generated will be created with 310 * {@link Distribution#UNIFORM}. 311 * 312 * @param <T> type of list elements generated 313 * @param content generator providing the content of lists generated 314 */ 315 public static <T> Generator<List<T>> nonEmptyLists(Generator<? extends T> content) { 316 return Generators.nonEmptyLists(content); 317 } 318 319 /** 320 * Create a generator of lists with values from the content generator. Length 321 * values of lists generated will be created with size generator. 322 * 323 * @param <T> type of list elements generated 324 * @param content generator providing the content of lists generated 325 * @param size integer used to determine the list size 326 */ 327 public static <T> Generator<List<T>> lists(Generator<? extends T> content, Generator<Integer> size) { 328 return Generators.lists(content, size); 329 } 330 331 /** 332 * Create a generator of lists with values from the content generator. Length is 333 * between high and low. 334 * 335 * @param <T> type of list elements generated 336 * @param content generator providing the content of lists generated 337 * @param low minimal size 338 * @param high max size 339 */ 340 public static <T> Generator<List<T>> lists(Generator<? extends T> content, int low, int high) { 341 return Generators.lists(content, low, high); 342 } 343 344 /** 345 * Create a generator of lists with values from the content generator. Length is 346 * at least low. 347 * 348 * @param <T> type of list elements generated 349 * @param content generator providing the content of lists generated 350 * @param low minimal size. If low is larger than 351 * {@link CombinedGenerators#DEFAULT_COLLECTION_MAX_SIZE} then it 352 * is the upper size bound as well. 353 */ 354 public static <T> Generator<List<T>> lists(Generator<? extends T> content, int low) { 355 return Generators.lists(content, low); 356 } 357 358 /** 359 * Create a generator of sorted lists with values from the content generator. 360 * 361 * @param <T> type of list elements generated 362 * @param content generator providing the content of lists generated 363 */ 364 public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content) { 365 return Generators.sortedLists(content); 366 367 } 368 369 /** 370 * Create a generator of sorted lists with values from the content generator. 371 * Length is between high and low. 372 * 373 * @param <T> type of list elements generated 374 * @param content generator providing the content of lists generated 375 * @param low minimal size 376 * @param high max size 377 */ 378 public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, int low, int high) { 379 return Generators.sortedLists(content, low, high); 380 381 } 382 383 /** 384 * Create a generator of sorted lists with values from the content generator. 385 * Length is between high and low. 386 * 387 * @param <T> type of list elements generated 388 * @param content generator providing the content of lists generated 389 * @param size integer used to determine the list size 390 */ 391 public static <T extends Comparable<T>> Generator<List<T>> sortedLists(Generator<T> content, 392 Generator<Integer> size) { 393 return Generators.sortedLists(content, size); 394 } 395 396 /** 397 * Create a generator of arrays with values from the content generator. Length 398 * values of array generated will be created with {@link Distribution#UNIFORM}. 399 * 400 * @param <T> type of arrays elements generated 401 * @param content generator providing the content of arrays generated 402 * @param type type of arrays generated 403 */ 404 public static <T> Generator<T[]> arrays(Generator<? extends T> content, Class<T> type) { 405 return Generators.arrays(content, type); 406 } 407 408 /** 409 * Create a generator of arrays that are not empty. 410 * 411 * @param <T> type of arrays elements generated 412 * @param content generator providing the content of arrays generated 413 * @param type type of arrays generated 414 */ 415 public static <T> Generator<T[]> nonEmptyArrays(Generator<? extends T> content, Class<T> type) { 416 return Generators.nonEmptyArrays(content, type); 417 } 418 419 /** 420 * Create a generator of arrays with values from the content generator. Length 421 * values of arrays generated will be created with size generator. 422 * 423 * @param <T> type of arrays elements generated 424 * @param content generator providing the content of arrays generated 425 * @param size integer used to determine the array size 426 * @param type type of arrays generated 427 */ 428 public static <T> Generator<T[]> arrays(Generator<? extends T> content, Generator<Integer> size, Class<T> type) { 429 return Generators.arrays(content, size, type); 430 } 431 432 /** 433 * Create a generator of byte arrays. The length of arrays generated will be 434 * determined by the {@link ByteArrayGenerator#MIN_SIZE} and 435 * {@link ByteArrayGenerator#MAX_SIZE} constants. 436 * 437 */ 438 public static Generator<byte[]> byteArrays() { 439 return Generators.byteArrays(); 440 } 441 442 /** 443 * Create a generator of byte arrays. Length values of arrays generated will be 444 * created with size generator. 445 * 446 * @param size integer used to determine the array size 447 */ 448 public static Generator<byte[]> byteArrays(Generator<Integer> size) { 449 return Generators.byteArrays(size); 450 } 451 452 /** 453 * Create a generator of byte arrays. Length values of arrays generated will be 454 * created with size generator. 455 * 456 * @param size integer used to determine the array size 457 * @param content generator for the byte array content 458 */ 459 public static Generator<byte[]> byteArrays(Generator<Byte> content, Generator<Integer> size) { 460 return Generators.byteArrays(content, size); 461 } 462 463 /** 464 * Create a generator of integer arrays. 465 * 466 */ 467 public static Generator<int[]> intArrays() { 468 return Generators.intArrays(); 469 } 470 471 /** 472 * Create a generator of integer arrays. Length values of arrays generated will 473 * be created with size generator. 474 * 475 * @param size integer used to determine the array size 476 */ 477 public static Generator<int[]> intArrays(Generator<Integer> size) { 478 return Generators.intArrays(size); 479 } 480 481 /** 482 * Create a generator of integer arrays. Length values of arrays generated will 483 * be created with size generator. 484 * 485 * @param size integer used to determine the array size 486 * @param content generator for the integer array content 487 */ 488 public static Generator<int[]> intArrays(Generator<Integer> content, Generator<Integer> size) { 489 return Generators.intArrays(content, size); 490 } 491 492 /** 493 * Create a generator of {@link Map maps}. 494 * 495 * <p> 496 * This is a generator for simple maps where the values are not related to the 497 * keys. 498 * </p> 499 * 500 * @param keys {@link Generator} for the keys of the map 501 * @param values {@link Generator} for the values of the map 502 */ 503 public static <K, V> Generator<Map<K, V>> maps(Generator<K> keys, Generator<V> values) { 504 return Generators.maps(keys, values); 505 } 506 507 /** 508 * Create a generator of {@link Map maps}. 509 * 510 * <p> 511 * This is a generator for simple maps where the values are not related to the 512 * keys. 513 * </p> 514 * 515 * @param keys {@link Generator} for the keys of the map 516 * @param values {@link Generator} for the values of the map 517 * @param size integer used to determine the size of the generated map 518 */ 519 public static <K, V> Generator<Map<K, V>> maps(Generator<K> keys, Generator<V> values, Generator<Integer> size) { 520 return Generators.maps(keys, values, size); 521 } 522 523 /** 524 * Create a generator of maps from a given map. 525 * 526 * <p> 527 * The entry set of the generated maps are subsets of the given map's entry set. 528 * </p> 529 * 530 * @param supermap of the generated maps 531 */ 532 public static <K, V> Generator<Map<K, V>> maps(Map<K, V> supermap) { 533 return Generators.maps(supermap); 534 } 535 536 /** 537 * Create a generator of maps from a given map. 538 * 539 * <p> 540 * The entry set of the generated maps are subsets of the given map's entry set. 541 * </p> 542 * 543 * @param supermap of the generated maps 544 * @param sizes of the generated maps 545 */ 546 public static <K, V> Generator<Map<K, V>> maps(Map<K, V> supermap, Generator<Integer> sizes) { 547 return Generators.maps(supermap, sizes); 548 } 549 550 /** 551 * Create a deterministic generator which guarantees that all values from the 552 * ensuredValues collection will be return {@link Generator#next()} are issued 553 * (i.e. ensuredValues.size() <= # of runs). The order of values is 554 * undefined. 555 * 556 * @param <T> type of values return 557 */ 558 public static <T> StatefulGenerator<T> ensureValues(Iterable<T> ensuredValues) { 559 return Generators.ensureValues(ensuredValues); 560 } 561 562 /** 563 * Create a deterministic generator which guarantees that all values from the 564 * ensuredValues array will be return {@link Generator#next()} are issued (i.e. 565 * ensuredValues.size() <= # of runs). The order of values is undefined. 566 * 567 * @param <T> type of values return 568 */ 569 @SafeVarargs 570 public static <T> StatefulGenerator<T> ensureValues(T... content) { 571 return Generators.ensureValues(content); 572 } 573 574 /** 575 * <p> 576 * Create a deterministic generator which guarantees that all values from the 577 * ensuredValues collection will be return {@link Generator#next()} are issued 578 * (i.e. ensuredValues.size() <= # of runs). The order of values is 579 * undefined. 580 * </p> 581 * <p> 582 * If all values of ensuredValues are generated calls to 583 * {@link Generator#next()} will return generator. 584 * </p> 585 * 586 * @param <T> type of values return 587 */ 588 public static <T> StatefulGenerator<T> ensureValues(Iterable<T> ensuredValues, Generator<T> otherValues) { 589 return Generators.ensureValues(ensuredValues, otherValues); 590 } 591 592 /** 593 * <p> 594 * Create a generator which guarantees that all values from the ensuredValues 595 * will be return {@link Generator#next()} are issued. 596 * </p> 597 * <p> 598 * The order of values is undefined. All other values in the window and after 599 * the window are taken from the {@link Generator generator otherValues}. 600 * </p> 601 * 602 * @param <T> type of values return 603 * @param window After window number of calls to {@link Generator#next()} it is 604 * guaranteed that all ensured values were return 605 */ 606 public static <T> StatefulGenerator<T> ensureValues(Iterable<T> ensuredValues, int window, 607 Generator<T> otherValues) { 608 return Generators.ensureValues(ensuredValues, window, otherValues); 609 } 610 611 /** 612 * <p> 613 * Create a generator that ensures unique values. 614 * </p> 615 * <p> 616 * The actual values are created with an arbitrary generator. 617 * </p> 618 * <p> 619 * Note: unique generator depends on valid implementation of equals and hashCode 620 * method of the content type generated. 621 * </p> 622 * 623 * @param <T> type of values return 624 * @param generator used to create the raw values. This generator can create 625 * duplicate values 626 * @param tries Number of tries to create a new unique value. After this 627 * number of tries is exceeded the generation aborts with a 628 * {@link GeneratorException}. 629 * @return unique generator instance 630 */ 631 public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, int tries) { 632 return Generators.uniqueValues(generator, tries); 633 } 634 635 /** 636 * <p> 637 * Create a generator that ensures unique values. 638 * </p> 639 * <p> 640 * The actual values are created with an arbitrary generator. 641 * </p> 642 * <p> 643 * Unique generator depends on the {@link Comparator} implementation to decide 644 * if two instances are the same (i.e. when the comparator return for 645 * {@link Comparator#compare(Object, Object)}). 646 * </p> 647 * 648 * @param <T> type of values return 649 * @param generator used to create the raw values. This generator can create 650 * duplicate values 651 * @param comparator that decides if two values are of the same equivalence 652 * class. 653 * @param tries Number of tries to create a new unique value. After this 654 * number of tries is exceeded the generation aborts with a 655 * {@link GeneratorException}. 656 * @return unique generator instance 657 */ 658 public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, Comparator<? super T> comparator, 659 int tries) { 660 return Generators.uniqueValues(generator, comparator, tries); 661 } 662 663 /** 664 * <p> 665 * Create a generator that ensures unique values. 666 * </p> 667 * <p> 668 * The actual values are created with an arbitrary generator. 669 * </p> 670 * <p> 671 * Unique generator depends on the {@link Comparator} implementation to decide 672 * if two instances are the same (i.e. when the comparator return for 673 * {@link Comparator#compare(Object, Object)}). 674 * </p> 675 * 676 * @param <T> type of values return 677 * @param generator used to create the raw values. This generator can create 678 * duplicate values 679 * @param comparator that decides if two values are of the same equivalence 680 * class. 681 * @return unique generator instance 682 */ 683 public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator, Comparator<? super T> comparator) { 684 return Generators.uniqueValues(generator, comparator); 685 } 686 687 /** 688 * <p> 689 * Create a generator that ensures unique values 690 * </p> 691 * <p> 692 * The actual values are created with an arbitrary generator. 693 * </p> 694 * <p> 695 * Note: unique generator depends on valid implementation of equals and hashCode 696 * method of the content type generated. 697 * </p> 698 * 699 * @param <T> type of values return 700 * @param generator used to create the raw values. This generator can create 701 * duplicate values 702 * @return unique generator instance 703 */ 704 public static <T> StatefulGenerator<T> uniqueValues(Generator<T> generator) { 705 return Generators.uniqueValues(generator); 706 } 707 708 /** 709 * Create a generator that omits a given set of values. 710 * 711 * @param generator used to create the raw values. 712 * @param excluded values. These values will not be return 713 */ 714 @SafeVarargs 715 public static <T> Generator<T> excludeValues(Generator<T> generator, T... excluded) { 716 return Generators.excludeValues(generator, excluded); 717 } 718 719 /** 720 * Create a generator that omits a given set of values. 721 * 722 * @param values of generator 723 * @param excluded values. These values will not be return 724 */ 725 @SafeVarargs 726 public static <T> Generator<T> excludeValues(Iterable<T> values, T... excluded) { 727 return Generators.excludeValues(values, excluded); 728 } 729 730 /** 731 * Create a generator that omits a given set of values. 732 * 733 * @param values of generator 734 * @param excluded values. These values will not be return 735 */ 736 public static <T> Generator<T> excludeValues(Iterable<T> values, Iterable<T> excluded) { 737 return Generators.excludeValues(values, excluded); 738 } 739 740 /** 741 * Create a generator that omits a given set of values. 742 * 743 * @param generator used to create the raw values. 744 * @param excluded values. These values will not be return 745 */ 746 public static <T> Generator<T> excludeValues(Generator<T> generator, Iterable<T> excluded) { 747 return Generators.excludeValues(generator, excluded); 748 } 749 750 /** 751 * A generator for a lists. The values in the lists are strictly increasing. 752 * <p> 753 * For every element x in the list: x(n) < x(n+1). 754 * </p> 755 * 756 * @param input values generator 757 */ 758 public static <T extends Comparable<T>> Generator<List<T>> strictlyOrdered(Generator<T> input) { 759 return Generators.strictlyOrdered(input); 760 } 761 762 /** 763 * A generator for a lists. The values in the lists are strictly increasing. 764 * 765 * <p> 766 * For every element x in the list: x(n) < x(n+1). 767 * </p> 768 * 769 * @param input values generator 770 * @param low minimum size of the lists 771 * @param high maximum size of the lists 772 */ 773 public static <T extends Comparable<T>> Generator<List<T>> strictlyOrdered(Generator<T> input, int low, int high) { 774 return Generators.strictlyOrdered(input, low, high); 775 } 776 777 /** 778 * A generator for a lists. The values in the lists are strictly increasing. 779 * <p> 780 * For every element x in the list: x(n) < x(n+1). 781 * </p> 782 * <p> 783 * This {@link Generator} can be used to generate a list of strictly decreasing 784 * values: 785 * {@code CombinedGenerators.strictlyOrdered(ts, Collections.<T> reverseOrder());} 786 * </p> 787 * 788 * 789 * @param input values generator 790 * @param comparator that orders the values 791 */ 792 public static <T> Generator<List<T>> strictlyOrdered(Generator<T> input, Comparator<T> comparator) { 793 return Generators.strictlyOrdered(input, comparator); 794 } 795 796 /** 797 * A generator for a lists. The values in the lists are strictly increasing. 798 * <p> 799 * For every element x in the list: x(n) < x(n+1). 800 * </p> 801 * 802 * @param input values generator 803 * @param comparator that orders the values 804 * @param size of the resulting lists 805 */ 806 public static <T> Generator<List<T>> strictlyOrdered(Generator<T> input, Comparator<T> comparator, 807 Generator<Integer> size) { 808 return Generators.strictlyOrdered(input, comparator, size); 809 } 810}