Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1619 - Add appending constructor to Joined iterable #1705

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/org/cactoos/iterable/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ public Joined(final Iterable<? extends Iterable<? extends T>> items) {
)
);
}

/**
* Ctor.
* @param item Item to be appended to end of Iterable
* @param items Iterable
* @since 0.65
*/
@SuppressWarnings("unchecked")
public Joined(final Iterable<? extends T> items, final T... item) {
this(new IterableOf<>(items, new IterableOf<>(item)));
}
}
13 changes: 13 additions & 0 deletions src/test/java/org/cactoos/iterable/JoinedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,17 @@ void joinItemAndIterable() {
).affirm();
}

@Test
@SuppressWarnings("unchecked")
void joinIterableAndItem() {
new Assertion<>(
"Must join item and iterable",
new Joined<>(
new IterableOf<>(1, 2, 3),
4, 5
),
new IsEqual<>(new IterableOf<>(1, 2, 3, 4, 5))
).affirm();
}

}