Used to create new intervals in an intuitive fashion by using the builder pattern. Since the implementation of the Interval class strives to avoid reflexion, despite being generic class, the Builder inner class is not static. Instead it is always tied to a particular object, so that
| 653 | * specific runtime type. |
| 654 | */ |
| 655 | public class Builder { |
| 656 | private Interval<T> interval; |
| 657 | |
| 658 | /** |
| 659 | * {@code private} constructor, used only in the internals of the {@link Interval} |
| 660 | * class. You can create new instances of the class by using either an existing |
| 661 | * object: |
| 662 | * <pre>existingInterval.builder()</pre> |
| 663 | * or by instantiating an "everything" interval with the default constructor and |
| 664 | * calling its {@link Interval#builder() builder} method: |
| 665 | * <pre>new IntegerInterval().builder()</pre> |
| 666 | * |
| 667 | * @param ref A reference object used only to determine the runtime type of the |
| 668 | * new object. The reference interval doesn't influence the start and |
| 669 | * end points of the new interval in any way. |
| 670 | */ |
| 671 | private Builder(Interval<T> ref){ |
| 672 | interval = ref.create(); |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Sets the start point of the currently building interval to the given value. |
| 677 | * The interval will be open to the left. If this method is called more than |
| 678 | * once or in conjunction with the {@link #greaterEqual(Comparable)} method, only |
| 679 | * the last call in the subsequence will take effect. |
| 680 | * |
| 681 | * @param start The value for the start point of the new interval. |
| 682 | */ |
| 683 | public Builder greater(T start){ |
| 684 | interval.start = start; |
| 685 | interval.isStartInclusive = false; |
| 686 | return this; |
| 687 | } |
| 688 | |
| 689 | /** |
| 690 | * Sets the start point of the currently building interval to the given value. |
| 691 | * The interval will be closed to the left. If this method is called more than |
| 692 | * once or in conjunction with the {@link #greater(Comparable)} method, only |
| 693 | * the last call in the subsequence will take effect. |
| 694 | * |
| 695 | * @param start The value for the start point of the new interval. |
| 696 | */ |
| 697 | public Builder greaterEqual(T start){ |
| 698 | interval.start = start; |
| 699 | interval.isStartInclusive = true; |
| 700 | return this; |
| 701 | } |
| 702 | |
| 703 | /** |
| 704 | * Sets the end point of the currently building interval to the given value. |
| 705 | * The interval will be open to the right. If this method is called more than |
| 706 | * once or in conjunction with the {@link #lessEqual(Comparable)} method, only |
| 707 | * the last call in the subsequence will take effect. |
| 708 | * |
| 709 | * @param end The value for the end point of the new interval. |
| 710 | */ |
| 711 | public Builder less(T end){ |
| 712 | interval.end = end; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…