From fa8d4a01ae8554f2cbc37047c30fbdd80be7b431 Mon Sep 17 00:00:00 2001 From: Fabricio Cabral Date: Tue, 27 Jun 2017 14:40:12 -0300 Subject: [PATCH] #248: JoinedText ctors more useful --- .../java/org/cactoos/text/JoinedText.java | 55 ++++++++----------- .../java/org/cactoos/text/JoinedTextTest.java | 2 +- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/main/java/org/cactoos/text/JoinedText.java b/src/main/java/org/cactoos/text/JoinedText.java index 0db0990cc8..8e734e2cff 100644 --- a/src/main/java/org/cactoos/text/JoinedText.java +++ b/src/main/java/org/cactoos/text/JoinedText.java @@ -52,54 +52,45 @@ public final class JoinedText implements Text { /** * Ctor. - * @param delimiter Delimit among texts - * @param texts Texts to be joined + * @param delimit Delimit among strings + * @param strs Strings to be joined */ - public JoinedText(final String delimiter, final String... texts) { - this( - new StringAsText(delimiter), - new MappedIterable<>( - new ArrayAsIterable<>(texts), - text -> new StringAsText(text) - ) - ); + public JoinedText(final String delimit, final String... strs) { + this(delimit, new ArrayAsIterable<>(strs)); } /** * Ctor. - * @param delimiter Delimit among texts - * @param texts Texts to be joined + * @param delimit Delimit among strings + * @param strs Strings to be joined */ - public JoinedText(final String delimiter, final Text... texts) { - this(delimiter, new ArrayAsIterable<>(texts)); - } - - /** - * Ctor. - * @param delimiter Delimit among texts - * @param texts Texts to be joined - */ - public JoinedText(final String delimiter, final Iterable texts) { - this(new StringAsText(delimiter), texts); + public JoinedText(final String delimit, final Iterable strs) { + this( + new StringAsText(delimit), + new MappedIterable<>( + strs, + text -> new StringAsText(text) + ) + ); } /** * Ctor. - * @param delimiter Delimit among texts - * @param texts Texts to be joined + * @param delimit Delimit among texts + * @param txts Texts to be joined */ - public JoinedText(final Text delimiter, final Text... texts) { - this(delimiter, new ArrayAsIterable<>(texts)); + public JoinedText(final Text delimit, final Text... txts) { + this(delimit, new ArrayAsIterable<>(txts)); } /** * Ctor. - * @param delimiter Delimit among texts - * @param texts Texts to be joined + * @param delimit Delimit among texts + * @param txts Texts to be joined */ - public JoinedText(final Text delimiter, final Iterable texts) { - this.delimiter = delimiter; - this.texts = texts; + public JoinedText(final Text delimit, final Iterable txts) { + this.delimiter = delimit; + this.texts = txts; } @Override diff --git a/src/test/java/org/cactoos/text/JoinedTextTest.java b/src/test/java/org/cactoos/text/JoinedTextTest.java index b5f971781c..d64b8b9bd3 100644 --- a/src/test/java/org/cactoos/text/JoinedTextTest.java +++ b/src/test/java/org/cactoos/text/JoinedTextTest.java @@ -51,7 +51,7 @@ public void joinsTexts() throws IOException { MatcherAssert.assertThat( "Can't join texts", new JoinedText( - " ", + new StringAsText(" "), new StringAsText("foo"), new StringAsText("bar") ),