Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 22, 2021
2 parents 6e62dc6 + ed23927 commit 8a34d58
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Abbreviated.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public final class Abbreviated extends TextEnvelope {
*
* <p> By default, the max line width is 80 characters.
*
* @param text The Text
* @param text The CharSequence
*/
public Abbreviated(final String text) {
public Abbreviated(final CharSequence text) {
this(new TextOf(text));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Base64Decoded.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public final class Base64Decoded extends TextEnvelope {
/**
* Ctor.
*
* @param input The String
* @param input The CharSequence
*/
public Base64Decoded(final String input) {
public Base64Decoded(final CharSequence input) {
this(new TextOf(input));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Base64Encoded.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public final class Base64Encoded extends TextEnvelope {
/**
* Ctor.
*
* @param input The String
* @param input The CharSequence
*/
public Base64Encoded(final String input) {
public Base64Encoded(final CharSequence input) {
this(new TextOf(input));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Capitalized.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Capitalized extends TextEnvelope {
*
* @param text The text
*/
public Capitalized(final String text) {
public Capitalized(final CharSequence text) {
this(new TextOf(text));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Concatenated.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public Concatenated(final Text... txts) {

/**
* Ctor.
* @param strs Strings to be concatenated
* @param strs CharSequences to be concatenated
*/
public Concatenated(final String... strs) {
public Concatenated(final CharSequence... strs) {
this(
new Mapped<>(
TextOf::new,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Contains.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class Contains implements Scalar<Boolean> {
* @param origin The origin
* @param other The other
*/
public Contains(final String origin, final String other) {
public Contains(final CharSequence origin, final CharSequence other) {
this(new TextOf(origin), new TextOf(other));
}

Expand All @@ -57,7 +57,7 @@ public Contains(final String origin, final String other) {
* @param origin The origin
* @param other The other
*/
public Contains(final String origin, final Text other) {
public Contains(final CharSequence origin, final Text other) {
this(new TextOf(origin), other);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/EndsWith.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public final class EndsWith implements Scalar<Boolean> {
* @param origin The origin
* @param suffix The suffix
*/
public EndsWith(final Text origin, final String suffix) {
public EndsWith(final Text origin, final CharSequence suffix) {
this(origin, new TextOf(suffix));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/FormattedText.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public FormattedText(
* @param ptn Pattern
* @param arguments Arguments
*/
public FormattedText(final String ptn, final Collection<Object> arguments) {
public FormattedText(final CharSequence ptn, final Collection<Object> arguments) {
this(ptn, Locale.getDefault(Locale.Category.FORMAT), arguments);
}

Expand All @@ -116,7 +116,7 @@ public FormattedText(final Text ptn, final Collection<Object> arguments) {
* @param arguments Arguments
*/
public FormattedText(
final String ptn,
final CharSequence ptn,
final Locale locale,
final Collection<Object> arguments
) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Joined extends TextEnvelope {
* @param delimit Delimit among strings
* @param strs Strings to be joined
*/
public Joined(final String delimit, final String... strs) {
public Joined(final CharSequence delimit, final CharSequence... strs) {
this(delimit, new IterableOf<>(strs));
}

Expand All @@ -51,7 +51,7 @@ public Joined(final String delimit, final String... strs) {
* @param delimit Delimit among strings
* @param strs Strings to be joined
*/
public Joined(final String delimit, final Iterable<String> strs) {
public Joined(final CharSequence delimit, final Iterable<? extends CharSequence> strs) {
this(
new TextOf(delimit),
new Mapped<>(TextOf::new, strs)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Lowered.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class Lowered extends TextEnvelope {
* Ctor.
* @param text The text
*/
public Lowered(final String text) {
public Lowered(final CharSequence text) {
this(new TextOf(text));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Mapped.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class Mapped extends TextEnvelope {
* @param fnc Function to apply
* @param txt Original text
*/
public Mapped(final Func<String, String> fnc, final Text txt) {
public Mapped(final Func<String, ? extends CharSequence> fnc, final Text txt) {
super(new TextOf(() -> fnc.apply(txt.asString())));
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/cactoos/text/Normalized.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class Normalized extends TextEnvelope {
* Ctor.
* @param text A Text
*/
public Normalized(final String text) {
public Normalized(final CharSequence text) {
this(new TextOf(text));
}

Expand All @@ -55,4 +55,3 @@ public Normalized(final Text text) {
);
}
}

14 changes: 6 additions & 8 deletions src/main/java/org/cactoos/text/PrefixOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
package org.cactoos.text;

import org.cactoos.Text;
import org.cactoos.func.FuncOf;
import org.cactoos.scalar.Constant;
import org.cactoos.scalar.ScalarOf;
import org.cactoos.scalar.Ternary;

Expand All @@ -40,10 +38,10 @@ public final class PrefixOf extends TextEnvelope {

/**
* Ctor.
* @param text Text representing the text value
* @param boundary String to which text will be split
* @param text CharSequence representing the text value
* @param boundary CharSequence to which text will be split
*/
public PrefixOf(final String text, final String boundary) {
public PrefixOf(final CharSequence text, final CharSequence boundary) {
this(new TextOf(text), boundary);
}

Expand All @@ -52,13 +50,13 @@ public PrefixOf(final String text, final String boundary) {
* @param text Text representing the text value
* @param boundary String to which text will be split
*/
public PrefixOf(final Text text, final String boundary) {
public PrefixOf(final Text text, final CharSequence boundary) {
super(
new Flattened(
new Ternary<>(
new ScalarOf<>(() -> new Sticky(text)),
(Text t) -> t.asString().indexOf(boundary) >= 0,
t -> new Sub(t, 0, s -> s.indexOf(boundary)),
(Text t) -> t.asString().contains(boundary.toString()),
t -> new Sub(t, 0, s -> s.indexOf(boundary.toString())),
t -> t
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Repeated.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class Repeated extends TextEnvelope {
* @param text A String
* @param count How many times repeat the Text
*/
public Repeated(final String text, final int count) {
public Repeated(final CharSequence text, final int count) {
this(new TextOf(text), count);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/cactoos/text/Split.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class Split extends IterableEnvelope<Text> {
* @param rgx The regex
* @see String#split(String)
*/
public Split(final String text, final String rgx) {
public Split(final CharSequence text, final CharSequence rgx) {
this(new TextOf(text), new TextOf(rgx));
}

Expand All @@ -56,7 +56,7 @@ public Split(final String text, final String rgx) {
* @param lmt The limit
* @see String#split(String, int)
*/
public Split(final String text, final String rgx, final int lmt) {
public Split(final CharSequence text, final CharSequence rgx, final int lmt) {
this(new TextOf(text), new TextOf(rgx), lmt);
}

Expand All @@ -66,7 +66,7 @@ public Split(final String text, final String rgx, final int lmt) {
* @param rgx The regex
* @see String#split(String)
*/
public Split(final String text, final Text rgx) {
public Split(final CharSequence text, final Text rgx) {
this(new TextOf(text), rgx);
}

Expand All @@ -87,7 +87,7 @@ public Split(final String text, final Text rgx, final int lmt) {
* @param rgx The regex
* @see String#split(String)
*/
public Split(final Text text, final String rgx) {
public Split(final Text text, final CharSequence rgx) {
this(text, new TextOf(rgx));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/StartsWith.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public StartsWith(final Text text, final Text prefix) {
* @param text The text
* @param prefix The prefix
*/
public StartsWith(final String text, final String prefix) {
public StartsWith(final CharSequence text, final CharSequence prefix) {
this(new TextOf(text), new TextOf(prefix));
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/text/Sub.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Sub extends TextEnvelope {
* @param text The String
* @param strt Start position in the text
*/
public Sub(final String text, final int strt) {
public Sub(final CharSequence text, final int strt) {
this(new TextOf(text), strt);
}

Expand All @@ -52,7 +52,7 @@ public Sub(final String text, final int strt) {
* @param strt Start position in the text
* @param finish End position in the text
*/
public Sub(final String text, final int strt, final int finish) {
public Sub(final CharSequence text, final int strt, final int finish) {
this(new TextOf(text), strt, finish);
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/cactoos/text/SuffixOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.cactoos.text;

import org.cactoos.Text;
import org.cactoos.scalar.LengthOf;
import org.cactoos.scalar.ScalarOf;
import org.cactoos.scalar.Ternary;

Expand All @@ -41,7 +42,7 @@ public final class SuffixOf extends TextEnvelope {
* @param text Text representing the text value
* @param boundary String after which text will be split
*/
public SuffixOf(final String text, final String boundary) {
public SuffixOf(final CharSequence text, final CharSequence boundary) {
this(new TextOf(text), boundary);
}

Expand All @@ -50,15 +51,16 @@ public SuffixOf(final String text, final String boundary) {
* @param text Text representing the text value
* @param boundary String after which text will be split
*/
public SuffixOf(final Text text, final String boundary) {
public SuffixOf(final Text text, final CharSequence boundary) {
super(
new Flattened(
new Ternary<>(
new ScalarOf<>(() -> new Sticky(text)),
(Text t) -> t.asString().indexOf(boundary) >= 0,
(Text t) -> t.asString().contains(boundary.toString()),
t -> new Sub(
t,
s -> s.indexOf(boundary) + boundary.length()
s -> s.indexOf(boundary.toString())
+ boundary.length()
),
t -> new TextOf("")
)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/cactoos/text/TextOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,20 @@ public TextOf(final Reader rdr, final int max, final Charset cset) {
/**
* Ctor.
*
* @param builder The String builder
* @param str The CharSequence
*/
public TextOf(final CharSequence builder) {
this(new BytesOf(builder));
public TextOf(final CharSequence str) {
this(new BytesOf(str));
}

/**
* Ctor.
*
* @param builder The String builder
* @param str The CharSequence
* @param cset The Charset
*/
public TextOf(final CharSequence builder, final Charset cset) {
this(new BytesOf(builder, cset), cset);
public TextOf(final CharSequence str, final Charset cset) {
this(new BytesOf(str, cset), cset);
}

/**
Expand Down Expand Up @@ -368,7 +368,7 @@ public TextOf(final InputStream input) {
*
* @param scalar The Scalar of String
*/
public TextOf(final Scalar<String> scalar) {
public TextOf(final Scalar<? extends CharSequence> scalar) {
this(new TextOfScalar(scalar));
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/cactoos/text/TextOfScalar.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@
public final class TextOfScalar implements Text {

/**
* String value of the envelope.
* Value of the envelope.
*/
private final Scalar<String> origin;
private final Scalar<? extends CharSequence> origin;

/**
* Ctor.
*
* @param scalar The Scalar of String
* @param scalar The scalar of CharSequence
*/
public TextOfScalar(final Scalar<String> scalar) {
public TextOfScalar(final Scalar<? extends CharSequence> scalar) {
this.origin = scalar;
}

@Override
public String asString() throws Exception {
return this.origin.value();
return this.origin.value().toString();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/text/Upper.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class Upper extends TextEnvelope {
* Ctor.
* @param text The text
*/
public Upper(final String text) {
public Upper(final CharSequence text) {
this(new TextOf(text));
}

Expand Down

0 comments on commit 8a34d58

Please sign in to comment.