Permalink
Browse files

#248: JoinedText ctors more useful

  • Loading branch information...
fabriciofx committed Jun 27, 2017
1 parent 286b19f commit fa8d4a01ae8554f2cbc37047c30fbdd80be7b431
Showing with 24 additions and 33 deletions.
  1. +23 −32 src/main/java/org/cactoos/text/JoinedText.java
  2. +1 −1 src/test/java/org/cactoos/text/JoinedTextTest.java
@@ -52,54 +52,45 @@
/**
* 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<Text> texts) {
this(new StringAsText(delimiter), texts);
public JoinedText(final String delimit, final Iterable<String> 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<Text> texts) {
this.delimiter = delimiter;
this.texts = texts;
public JoinedText(final Text delimit, final Iterable<Text> txts) {
this.delimiter = delimit;
this.texts = txts;
}
@Override
@@ -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")
),

0 comments on commit fa8d4a0

Please sign in to comment.