Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/java/org/cactoos/io/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,25 @@ public final class Joined implements Input {
*/
private final Iterable<Input> inputs;

/**
* Ctor.
* @param inputs Iterable of inputs
*/
public Joined(final Iterable<Input> inputs) {
this.inputs = inputs;
}

/**
* Ctor.
* @param first First input
* @param rest The rest
*/
public Joined(final Input first, final Input... rest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyakharlamov Same above.

this.inputs = new org.cactoos.iterable.Joined<>(
first,
new IterableOf<>(rest)
this(
new org.cactoos.iterable.Joined<>(
first,
new IterableOf<>(rest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilyakharlamov Same above.

)
);
}

Expand Down
21 changes: 21 additions & 0 deletions src/test/java/org/cactoos/io/JoinedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.cactoos.io;

import java.io.IOException;
import org.cactoos.iterable.IterableOf;
import org.cactoos.text.TextOf;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
Expand Down Expand Up @@ -52,4 +53,24 @@ public void joinsOk() throws IOException {
new TextHasString("firstsecondthird")
);
}

/**
* Must join inputs of the iterable in the given order.
*/
@Test
public void fromIterable() {
MatcherAssert.assertThat(
"Cannot join iterable of inputs",
new TextOf(
new Joined(
new IterableOf<>(
new InputOf("ab"),
new InputOf("cde"),
new InputOf("fghi")
)
)
),
new TextHasString("abcdefghi")
);
}
}