Skip to content

Commit

Permalink
(yegor256#1462) Use text.Mapped
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoss committed Oct 16, 2020
1 parent 6615a28 commit 8996680
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main/java/org/cactoos/text/TrimmedLeft.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
/**
* Text without control characters (char <= 32) only from left.
*
* <p>There is no thread-safety guarantee.
* <p>
* There is no thread-safety guarantee.
*
* @since 0.12
*/
Expand All @@ -40,17 +41,19 @@ public final class TrimmedLeft extends TextEnvelope {
*/
public TrimmedLeft(final Text text) {
super(
new TextOf(
() -> {
final String string = text.asString();
new Mapped(
string -> {
int cursor = 0;
while (cursor < string.length() && Character.isWhitespace(
string.charAt(cursor)
)) {
while (
cursor < string.length() && Character.isWhitespace(
string.charAt(cursor)
)
) {
cursor = cursor + 1;
}
return string.substring(cursor);
}
},
text
)
);
}
Expand Down

0 comments on commit 8996680

Please sign in to comment.