yegor256 / cactoos

@@ -24,6 +24,7 @@
Loading
24 24
package org.cactoos.text;
25 25
26 26
import org.cactoos.Text;
27 +
import org.cactoos.scalar.LengthOf;
27 28
import org.cactoos.scalar.ScalarOf;
28 29
import org.cactoos.scalar.Ternary;
29 30
@@ -41,7 +42,7 @@
Loading
41 42
     * @param text Text representing the text value
42 43
     * @param boundary String after which text will be split
43 44
     */
44 -
    public SuffixOf(final String text, final String boundary) {
45 +
    public SuffixOf(final CharSequence text, final CharSequence boundary) {
45 46
        this(new TextOf(text), boundary);
46 47
    }
47 48
@@ -50,15 +51,23 @@
Loading
50 51
     * @param text Text representing the text value
51 52
     * @param boundary String after which text will be split
52 53
     */
53 -
    public SuffixOf(final Text text, final String boundary) {
54 +
    public SuffixOf(final Text text, final CharSequence boundary) {
55 +
        this(text, new TextOf(boundary));
56 +
    }
57 +
    /**
58 +
     * Ctor.
59 +
     * @param text Text representing the text value
60 +
     * @param boundary String after which text will be split
61 +
     */
62 +
    public SuffixOf(final Text text, final Text boundary) {
54 63
        super(
55 64
            new Flattened(
56 65
                new Ternary<>(
57 66
                    new ScalarOf<>(() -> new Sticky(text)),
58 -
                    (Text t) -> t.asString().indexOf(boundary) >= 0,
67 +
                    (Text t) -> t.asString().indexOf(boundary.asString()) >= 0,
59 68
                    t -> new Sub(
60 69
                        t,
61 -
                        s -> s.indexOf(boundary) + boundary.length()
70 +
                        s -> s.indexOf(boundary.asString()) + new LengthOf(boundary).value().intValue()
62 71
                    ),
63 72
                    t -> new TextOf("")
64 73
                )

@@ -43,7 +43,7 @@
Loading
43 43
     * @param text Text representing the text value
44 44
     * @param boundary String to which text will be split
45 45
     */
46 -
    public PrefixOf(final CharSequence text, final String boundary) {
46 +
    public PrefixOf(final CharSequence text, final CharSequence boundary) {
47 47
        this(new TextOf(text), boundary);
48 48
    }
49 49
@@ -52,13 +52,22 @@
Loading
52 52
     * @param text Text representing the text value
53 53
     * @param boundary String to which text will be split
54 54
     */
55 -
    public PrefixOf(final Text text, final String boundary) {
55 +
    public PrefixOf(final Text text, final CharSequence boundary) {
56 +
        this(text, new TextOf(boundary));
57 +
    }
58 +
59 +
    /**
60 +
     * Ctor.
61 +
     * @param text Text representing the text value
62 +
     * @param boundary String to which text will be split
63 +
     */
64 +
    public PrefixOf(final Text text, final Text boundary) {
56 65
        super(
57 66
            new Flattened(
58 67
                new Ternary<>(
59 68
                    new ScalarOf<>(() -> new Sticky(text)),
60 -
                    (Text t) -> t.asString().indexOf(boundary) >= 0,
61 -
                    t -> new Sub(t, 0, s -> s.indexOf(boundary)),
69 +
                    (Text t) -> t.asString().indexOf(boundary.asString()) >= 0,
70 +
                    t -> new Sub(t, 0, s -> s.indexOf(boundary.asString())),
62 71
                    t -> t
63 72
                )
64 73
            )
Files Complexity Coverage
src/main/java/org/cactoos 88.35% 90.26%
Project Totals (302 files) 88.35% 90.26%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading