提交 cc83bf0e 编写于 作者: J Josh Soref 提交者: Oleg Nenashev

Introduce new Run#getBuildsOverThreshold() method for getting runs above the...

Introduce new Run#getBuildsOverThreshold() method for getting runs above the desired execution result (#4259)

* IntelliJ/Java: Duplicate code

Refactored as Run.getBuildsOverThreshold

* CheckForNull
Co-Authored-By: NOleg Nenashev <o.v.nenashev@gmail.com>

* getBuildsOverThreshold: get RunT using _this()
上级 987ca985
......@@ -994,19 +994,8 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* if not enough builds satisfying the threshold have been found. Never null.
*/
public List<RunT> getLastBuildsOverThreshold(int numberOfBuilds, Result threshold) {
List<RunT> result = new ArrayList<>(numberOfBuilds);
RunT r = getLastBuild();
while (r != null && result.size() < numberOfBuilds) {
if (!r.isBuilding() &&
(r.getResult() != null && r.getResult().isBetterOrEqualTo(threshold))) {
result.add(r);
}
r = r.getPreviousBuild();
}
return result;
return r.getBuildsOverThreshold(numberOfBuilds, threshold);
}
/**
......
......@@ -953,9 +953,24 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* @since 1.383
*/
public @Nonnull List<RunT> getPreviousBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) {
RunT r = getPreviousBuild();
return r.getBuildsOverThreshold(numberOfBuilds, threshold);
}
/**
* Returns the last {@code numberOfBuilds} builds with a build result ≥ {@code threshold}.
*
* @param numberOfBuilds the desired number of builds
* @param threshold the build result threshold
* @return a list with the builds (youngest build first).
* May be smaller than 'numberOfBuilds' or even empty
* if not enough builds satisfying the threshold have been found. Never null.
* @since TODO
*/
protected @Nonnull List<RunT> getBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) {
List<RunT> builds = new ArrayList<>(numberOfBuilds);
RunT r = getPreviousBuild();
RunT r = _this();
while (r != null && builds.size() < numberOfBuilds) {
if (!r.isBuilding() &&
(r.getResult() != null && r.getResult().isBetterOrEqualTo(threshold))) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册