A leaf node in a Doc for an optional break.
| 557 | |
| 558 | /** A leaf node in a {@link Doc} for an optional break. */ |
| 559 | public static final class Break extends Doc implements Op { |
| 560 | private final FillMode fillMode; |
| 561 | private final String flat; |
| 562 | private final Indent plusIndent; |
| 563 | private final Optional<BreakTag> optTag; |
| 564 | |
| 565 | private Break(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakTag> optTag) { |
| 566 | this.fillMode = fillMode; |
| 567 | this.flat = flat; |
| 568 | this.plusIndent = plusIndent; |
| 569 | this.optTag = optTag; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Make a {@code Break}. |
| 574 | * |
| 575 | * @param fillMode the {@link FillMode} |
| 576 | * @param flat the text when not broken |
| 577 | * @param plusIndent extra indent if taken |
| 578 | * @return the new {@code Break} |
| 579 | */ |
| 580 | public static Break make(FillMode fillMode, String flat, Indent plusIndent) { |
| 581 | return new Break(fillMode, flat, plusIndent, /* optTag= */ Optional.empty()); |
| 582 | } |
| 583 | |
| 584 | /** |
| 585 | * Make a {@code Break}. |
| 586 | * |
| 587 | * @param fillMode the {@link FillMode} |
| 588 | * @param flat the text when not broken |
| 589 | * @param plusIndent extra indent if taken |
| 590 | * @param optTag an optional tag for remembering whether the break was taken |
| 591 | * @return the new {@code Break} |
| 592 | */ |
| 593 | public static Break make( |
| 594 | FillMode fillMode, String flat, Indent plusIndent, Optional<BreakTag> optTag) { |
| 595 | return new Break(fillMode, flat, plusIndent, optTag); |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Make a forced {@code Break}. |
| 600 | * |
| 601 | * @return the new forced {@code Break} |
| 602 | */ |
| 603 | public static Break makeForced() { |
| 604 | return make(FillMode.FORCED, "", Indent.Const.ZERO); |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Return the {@code Break}'s extra indent. |
| 609 | * |
| 610 | * @return the extra indent |
| 611 | */ |
| 612 | int getPlusIndent() { |
| 613 | return plusIndent.eval(); |
| 614 | } |
| 615 | |
| 616 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…