Skip to content

Commit 7bccd7a

Browse files
authored
Merge pull request #7 from dykov/add-next-method
Edit method descriptions
2 parents b3458b0 + 3baccf9 commit 7bccd7a

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/main/java/io/github/dgroup/enumerable4j/Enumerable.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public interface Enumerable<X> extends Collection<X> {
4747

4848
/**
4949
* Passes each element of the collection to the given block.
50+
* If no predicate (null) is given, then true is returned instead.
5051
* @param prd The predicate to match each element.
5152
* @return The true if the block never returns false or nil.
5253
*/
@@ -62,6 +63,7 @@ default boolean all(Predicate<X> prd) {
6263

6364
/**
6465
* Passes at least one element of the collection to the given block.
66+
* If no predicate (null) is given, then true is returned instead.
6567
* @param prd The predicate to match at least one element.
6668
* @return The true if the block never returns false or nil.
6769
*/
@@ -77,6 +79,7 @@ default boolean any(Predicate<X> prd) {
7779

7880
/**
7981
* Doesn't passes elements of the collection to the given block.
82+
* If no predicate (null) is given, then true is returned instead.
8083
* @param prd The predicate to match none elements.
8184
* @return The true if the block never returns false or nil.
8285
*/
@@ -159,7 +162,7 @@ default X find(Predicate<X> prd, X alt) {
159162

160163
/**
161164
* Returns an enumerable containing all elements, on which given function was applied.
162-
* If no function (null) is given, then 'this' is returned instead.
165+
* If no function (null) is given, then empty enumerable is returned instead.
163166
* @param fnc The function to apply to each element.
164167
* @param <Y> The type of target entity.
165168
* @return The enumerable.
@@ -197,7 +200,6 @@ default long count(Predicate<X> prd) {
197200
* Returns a result of the reduction of the elements in this stream,
198201
* using provided identity value and accumulation function operator.
199202
* If no function (null) is given, then identity is returned instead.
200-
*
201203
* @param idn The identity value of the accumulation function.
202204
* @param opr The accumulation function operator which combining previous and current values.
203205
* @return Result of of combining elements.
@@ -230,6 +232,7 @@ default Enumerable<X> after(Predicate<X> prd) {
230232
* @param prd The function to match element after which enumerable elements should be returned.
231233
* @param size The number of elements the enumerable should be limited to.
232234
* @return The enumerable.
235+
* @throws IllegalArgumentException If the size is negative.
233236
*/
234237
default Enumerable<X> after(Predicate<X> prd, long size) {
235238
final Enumerable<X> out;

src/test/java/io/github/dgroup/enumerable4j/FindTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void altFind() {
7777
@Test
7878
void altNullPredicate() {
7979
new Assertion<>(
80-
"In case of null predicate we will get the same enumerable",
80+
"In case of null predicate, we get the alternative result",
8181
new Linked<>(1, 2, 3).find(null, 100),
8282
new IsEqual<>(100)
8383
).affirm();

src/test/java/io/github/dgroup/enumerable4j/MapTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package io.github.dgroup.enumerable4j;
2626

2727
import org.hamcrest.collection.IsEmptyIterable;
28+
import org.hamcrest.core.AllOf;
2829
import org.hamcrest.core.IsNot;
2930
import org.junit.jupiter.api.Test;
3031
import org.llorllale.cactoos.matchers.Assertion;
@@ -42,7 +43,7 @@ final class MapTest {
4243
@Test
4344
void map() {
4445
new Assertion<>(
45-
"All numbers where multiplied on 10",
46+
"All numbers are multiplied by 10",
4647
new Linked<>(2, 3, 4).map(val -> val * 10),
4748
new HasValues<>(20, 30, 40)
4849
).affirm();
@@ -51,7 +52,7 @@ void map() {
5152
@Test
5253
void nullFunction() {
5354
new Assertion<>(
54-
"All numbers are the same",
55+
"In case null-function, an empty enumerable is returned",
5556
new Linked<>(2, 3, 4).map(null),
5657
new IsEmptyIterable<>()
5758
).affirm();
@@ -62,8 +63,9 @@ void negative() {
6263
new Assertion<>(
6364
"All numbers converted to numbers squares",
6465
new Linked<>(0, 1, 2, 3).map(val -> val * val),
65-
new IsNot<>(
66-
new HasValues<>(5, 7, 9)
66+
new AllOf<>(
67+
new IsNot<>(new HasValues<>(5, 7, 9)),
68+
new HasValues<>(0, 1, 4, 9)
6769
)
6870
).affirm();
6971
}

src/test/java/io/github/dgroup/enumerable4j/NoneTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package io.github.dgroup.enumerable4j;
2626

27-
import org.hamcrest.core.IsEqual;
2827
import org.junit.jupiter.api.Test;
2928
import org.llorllale.cactoos.matchers.Assertion;
3029
import org.llorllale.cactoos.matchers.IsTrue;
@@ -52,7 +51,7 @@ void negative() {
5251
new Assertion<>(
5352
"All values in enumerable are negative",
5453
new Linked<>(1, 2, 3).none(val -> val < 0),
55-
new IsEqual<>(true)
54+
new IsTrue()
5655
).affirm();
5756
}
5857

0 commit comments

Comments
 (0)