Skip to content

Commit

Permalink
#loops: more
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 21, 2017
1 parent 235a672 commit 6f03805
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 598 deletions.
80 changes: 0 additions & 80 deletions src/main/java/org/cactoos/func/AlwaysTrueFunc.java

This file was deleted.

19 changes: 14 additions & 5 deletions src/main/java/org/cactoos/func/And.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.util.Iterator;
import org.cactoos.Scalar;
import org.cactoos.list.ArrayAsIterable;

/**
* Logical conjunction.
Expand All @@ -44,16 +45,24 @@ public final class And implements Scalar<Boolean> {

/**
* Ctor.
* @param iterable The iterable
* @param src The iterable
*/
public And(final Iterable<Scalar<Boolean>> iterable) {
this.iterable = iterable;
@SafeVarargs
public And(final Scalar<Boolean>... src) {
this(new ArrayAsIterable<>(src));
}

/**
* Ctor.
* @param src The iterable
*/
public And(final Iterable<Scalar<Boolean>> src) {
this.iterable = src;
}

@Override
public Boolean asValue() throws Exception {
final Iterator<Scalar<Boolean>> iterator = this.iterable.iterator();
return this.conjunction(iterator, true);
return this.conjunction(this.iterable.iterator(), true);
}

/**
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/org/cactoos/func/Or.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.util.Iterator;
import org.cactoos.Scalar;
import org.cactoos.list.ArrayAsIterable;

/**
* Logical disjunction.
Expand All @@ -44,16 +45,24 @@ public final class Or implements Scalar<Boolean> {

/**
* Ctor.
* @param iterable The iterable
* @param src The iterable
*/
public Or(final Iterable<Scalar<Boolean>> iterable) {
this.iterable = iterable;
@SafeVarargs
public Or(final Scalar<Boolean>... src) {
this(new ArrayAsIterable<>(src));
}

/**
* Ctor.
* @param src The iterable
*/
public Or(final Iterable<Scalar<Boolean>> src) {
this.iterable = src;
}

@Override
public Boolean asValue() throws Exception {
final Iterator<Scalar<Boolean>> iterator = this.iterable.iterator();
return this.disjunction(iterator, false);
return this.disjunction(this.iterable.iterator(), false);
}

/**
Expand Down
92 changes: 0 additions & 92 deletions src/main/java/org/cactoos/list/AllOf.java

This file was deleted.

64 changes: 0 additions & 64 deletions src/main/java/org/cactoos/list/AnyOf.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/org/cactoos/list/FilteredIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean hasNext() {
public X next() {
if (!this.hasNext()) {
throw new NoSuchElementException(
"No more elements with fits the condition."
"No more elements that fit the condition"
);
}
return this.buffer.poll();
Expand All @@ -109,7 +109,7 @@ public X next() {
@Override
public void remove() {
throw new UnsupportedOperationException(
"FilteredIterator does not support remove Operation"
"#remove() is not supported"
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cactoos/list/ItemOfIterable.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public ItemOfIterable(final Iterable<T> src, final int pos) {
itr -> {
throw new IOException(
new FormattedText(
"Iterable %s hasn't element from position %d",
"Iterable %s doesn't have element at position #%d",
itr,
pos
).asString()
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/cactoos/list/ItemOfIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ public ItemOfIterator(final Iterator<T> src) {
this(
src,
itr -> {
throw new IOException(
new FormattedText("Iterator %s is empty", itr.iterator())
.asString()
);
throw new IOException("Iterator is empty");
}
);
}
Expand Down Expand Up @@ -110,8 +107,7 @@ public ItemOfIterator(final Iterator<T> src, final int pos) {
itr -> {
throw new IOException(
new FormattedText(
"Iterator %s hasn't element from position %d",
itr.iterator(),
"Iterator doesn't have an element at #%d position",
pos
).asString()
);
Expand Down Expand Up @@ -141,7 +137,7 @@ public T asValue() throws Exception {
if (this.pos < 0) {
throw new IOException(
new FormattedText(
"Position must be nonnegative! But position = %d",
"The position must be non-negative: %d",
this.pos
).asString()
);
Expand Down
Loading

0 comments on commit 6f03805

Please sign in to comment.