Skip to content

Commit

Permalink
(yegor256#1462) Use Mapped when relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed Dec 27, 2020
1 parent 77f163f commit 0d99c73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions src/main/java/org/cactoos/text/FormattedText.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,15 @@ public FormattedText(
final Collection<Object> args
) {
super(
new TextOf(
() -> {
final StringBuilder out = new StringBuilder(0);
new Mapped(
pattern -> {
final StringBuilder out = new StringBuilder(pattern.length());
try (Formatter fmt = new Formatter(out, locale)) {
fmt.format(
ptn.asString(),
args.toArray()
);
fmt.format(pattern, args.toArray());
}
return out.toString();
}
},
ptn
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/cactoos/text/Rotated.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public final class Rotated extends TextEnvelope {
*/
public Rotated(final Text text, final int shift) {
super(
new TextOf(
() -> {
String origin = text.asString();
new Mapped(
origin -> {
final int length = origin.length();
if (length != 0 && shift != 0 && shift % length != 0) {
final StringBuilder builder = new StringBuilder(length);
Expand All @@ -55,7 +54,8 @@ public Rotated(final Text text, final int shift) {
).toString();
}
return origin;
}
},
text
)
);
}
Expand Down

0 comments on commit 0d99c73

Please sign in to comment.