Skip to content

Commit

Permalink
Merge pull request #7 from dykov/add-next-method
Browse files Browse the repository at this point in the history
Edit method descriptions
  • Loading branch information
dykov authored May 8, 2021
2 parents b3458b0 + 3baccf9 commit 7bccd7a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/main/java/io/github/dgroup/enumerable4j/Enumerable.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface Enumerable<X> extends Collection<X> {

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

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

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

/**
* Returns an enumerable containing all elements, on which given function was applied.
* If no function (null) is given, then 'this' is returned instead.
* If no function (null) is given, then empty enumerable is returned instead.
* @param fnc The function to apply to each element.
* @param <Y> The type of target entity.
* @return The enumerable.
Expand Down Expand Up @@ -197,7 +200,6 @@ default long count(Predicate<X> prd) {
* Returns a result of the reduction of the elements in this stream,
* using provided identity value and accumulation function operator.
* If no function (null) is given, then identity is returned instead.
*
* @param idn The identity value of the accumulation function.
* @param opr The accumulation function operator which combining previous and current values.
* @return Result of of combining elements.
Expand Down Expand Up @@ -230,6 +232,7 @@ default Enumerable<X> after(Predicate<X> prd) {
* @param prd The function to match element after which enumerable elements should be returned.
* @param size The number of elements the enumerable should be limited to.
* @return The enumerable.
* @throws IllegalArgumentException If the size is negative.
*/
default Enumerable<X> after(Predicate<X> prd, long size) {
final Enumerable<X> out;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/github/dgroup/enumerable4j/FindTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void altFind() {
@Test
void altNullPredicate() {
new Assertion<>(
"In case of null predicate we will get the same enumerable",
"In case of null predicate, we get the alternative result",
new Linked<>(1, 2, 3).find(null, 100),
new IsEqual<>(100)
).affirm();
Expand Down
10 changes: 6 additions & 4 deletions src/test/java/io/github/dgroup/enumerable4j/MapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package io.github.dgroup.enumerable4j;

import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsNot;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
Expand All @@ -42,7 +43,7 @@ final class MapTest {
@Test
void map() {
new Assertion<>(
"All numbers where multiplied on 10",
"All numbers are multiplied by 10",
new Linked<>(2, 3, 4).map(val -> val * 10),
new HasValues<>(20, 30, 40)
).affirm();
Expand All @@ -51,7 +52,7 @@ void map() {
@Test
void nullFunction() {
new Assertion<>(
"All numbers are the same",
"In case null-function, an empty enumerable is returned",
new Linked<>(2, 3, 4).map(null),
new IsEmptyIterable<>()
).affirm();
Expand All @@ -62,8 +63,9 @@ void negative() {
new Assertion<>(
"All numbers converted to numbers squares",
new Linked<>(0, 1, 2, 3).map(val -> val * val),
new IsNot<>(
new HasValues<>(5, 7, 9)
new AllOf<>(
new IsNot<>(new HasValues<>(5, 7, 9)),
new HasValues<>(0, 1, 4, 9)
)
).affirm();
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/io/github/dgroup/enumerable4j/NoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package io.github.dgroup.enumerable4j;

import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.IsTrue;
Expand Down Expand Up @@ -52,7 +51,7 @@ void negative() {
new Assertion<>(
"All values in enumerable are negative",
new Linked<>(1, 2, 3).none(val -> val < 0),
new IsEqual<>(true)
new IsTrue()
).affirm();
}

Expand Down

0 comments on commit 7bccd7a

Please sign in to comment.