Skip to content

Commit 1642c69

Browse files
committed
Add new constructor that takes an action
1 parent 98f9704 commit 1642c69

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/main/java/io/jenkins/plugins/echarts/GenericBuildActionIterator.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package io.jenkins.plugins.echarts;
22

3+
import edu.hm.hafner.echarts.Build;
4+
import edu.hm.hafner.echarts.BuildResult;
5+
import edu.umd.cs.findbugs.annotations.NonNull;
6+
37
import java.util.Iterator;
48
import java.util.NoSuchElementException;
59
import java.util.Optional;
610
import java.util.function.Function;
711
import java.util.function.Predicate;
812

9-
import edu.hm.hafner.echarts.Build;
10-
import edu.hm.hafner.echarts.BuildResult;
11-
1213
import hudson.model.Run;
1314

1415
import io.jenkins.plugins.util.BuildAction;
@@ -77,6 +78,23 @@ public static class BuildActionIterable<A extends BuildAction<?>, R> implements
7778
private final Predicate<A> filter;
7879
private final Function<A, R> function;
7980

81+
/**
82+
* Creates a new instance of {@link BuildActionIterable}.
83+
*
84+
* @param actionType
85+
* the type of the action to select
86+
* @param latestAction
87+
* the latest action that will be used as starting point for the sequence of results
88+
* @param filter
89+
* filter that selects the action (if there are multiple actions of the same type)
90+
* @param function
91+
* the supplier that extracts the specific results from the action
92+
*/
93+
public BuildActionIterable(final Class<A> actionType, final A latestAction,
94+
final Predicate<A> filter, final Function<A, R> function) {
95+
this(actionType, Optional.of(latestAction), filter, function);
96+
}
97+
8098
/**
8199
* Creates a new instance of {@link BuildActionIterable}.
82100
*
@@ -97,6 +115,7 @@ public BuildActionIterable(final Class<A> actionType, final Optional<A> latestAc
97115
this.function = function;
98116
}
99117

118+
@NonNull
100119
@Override
101120
public Iterator<BuildResult<R>> iterator() {
102121
return new GenericBuildActionIterator<>(actionType, latestAction, filter, function);

0 commit comments

Comments
 (0)