Skip to content

Commit

Permalink
validate for null
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 19, 2017
1 parent b83c546 commit 5771bc8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/cactoos/func/RepeatedFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.cactoos.func;

import org.cactoos.Func;
import org.cactoos.text.FormattedText;

/**
* Func that repeats its calculation a few times before
Expand Down Expand Up @@ -67,6 +68,14 @@ public Y apply(final X input) throws Exception {
for (int idx = 0; idx < this.times; ++idx) {
result = this.func.apply(input);
}
if (result == null) {
throw new IllegalArgumentException(
new FormattedText(
"Repeat counter is equal or less than zero: %d",
this.times
).asString()
);
}
return result;
}

Expand Down

0 comments on commit 5771bc8

Please sign in to comment.