提交 457315f4 编写于 作者: K kohsuke

Using two type parameters was causing too much problem, as illustrated in the...

Using two type parameters was causing too much problem, as illustrated in the following. Falling back to one type argument version, which is much easier to handle:
------------------
import java.util.ArrayList;

class Job<J extends Job<J,R>, R extends Run<J,R>> {}
class Run<J extends Job<J,R>, R extends Run<J,R>> {}

class Job2 extends Job<Job2,Run2> {}
class Run2 extends Run<Job2,Run2> {}

class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R> {}

class Foo {
    // how do I make this work?
    public void test1(RunList<Job,Run> why) {}

    // this works
    public void test2(RunList<Job2,Run2> why) {}
}

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34043 71c3de6d-444a-0410-be80-ed276b4c234a
上级 be28fe6d
......@@ -45,9 +45,9 @@ import java.util.Date;
* @since 1.372
*/
public class BuildTimelineWidget {
protected final RunList<?,?> builds;
protected final RunList<?> builds;
public BuildTimelineWidget(RunList<?,?> builds) {
public BuildTimelineWidget(RunList<?> builds) {
this.builds = builds;
}
......
......@@ -588,7 +588,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
@Exported
@WithBridgeMethods(List.class)
public RunList<JobT,RunT> getBuilds() {
public RunList<RunT> getBuilds() {
return RunList.fromRuns(_getRuns().values());
}
......@@ -645,7 +645,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* as of 1.372. Should just do {@code getBuilds().byTimestamp(s,e)} to avoid code bloat in {@link Job}.
*/
@WithBridgeMethods(List.class)
public RunList<JobT,RunT> getBuildsByTimestamp(long start, long end) {
public RunList<RunT> getBuildsByTimestamp(long start, long end) {
return getBuilds().byTimestamp(start,end);
}
......
......@@ -48,11 +48,11 @@ import java.util.List;
*
* @author Kohsuke Kawaguchi
*/
public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R> {
public class RunList<R extends Run> extends ArrayList<R> {
public RunList() {
}
public RunList(J j) {
public RunList(Job j) {
addAll(j.getBuilds());
}
......@@ -71,8 +71,8 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
Collections.sort(this,Run.ORDER_BY_DATE);
}
public RunList(Collection<? extends J> jobs) {
for (J j : jobs)
public RunList(Collection<? extends Job> jobs) {
for (Job j : jobs)
addAll(j.getBuilds());
Collections.sort(this,Run.ORDER_BY_DATE);
}
......@@ -81,15 +81,15 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
super(c);
}
public static <J extends Job<J,R>,R extends Run<J,R>>
RunList<J,R> fromRuns(Collection<? extends R> runs) {
return new RunList<J,R>(runs,false);
public static <R extends Run>
RunList<R> fromRuns(Collection<? extends R> runs) {
return new RunList<R>(runs,false);
}
/**
* Filter the list to non-successful builds only.
*/
public RunList<J,R> failureOnly() {
public RunList<R> failureOnly() {
for (Iterator<R> itr = iterator(); itr.hasNext();) {
Run r = itr.next();
if(r.getResult()==Result.SUCCESS)
......@@ -101,7 +101,7 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
/**
* Filter the list to builds on a single node only
*/
public RunList<J,R> node(Node node) {
public RunList<R> node(Node node) {
for (Iterator<R> itr = iterator(); itr.hasNext();) {
Run r = itr.next();
if (!(r instanceof AbstractBuild) || ((AbstractBuild)r).getBuiltOn()!=node) {
......@@ -114,7 +114,7 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
/**
* Filter the list to regression builds only.
*/
public RunList<J,R> regressionOnly() {
public RunList<R> regressionOnly() {
for (Iterator<R> itr = iterator(); itr.hasNext();) {
Run r = itr.next();
if(!r.getBuildStatusSummary().isWorse)
......@@ -128,7 +128,7 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
*
* {@code s&lt=;e}.
*/
public RunList<J,R> byTimestamp(long start, long end) {
public RunList<R> byTimestamp(long start, long end) {
AbstractList<Long> TIMESTAMP_ADAPTER = new AbstractList<Long>() {
public Long get(int index) {
return RunList.this.get(index).getTimeInMillis();
......@@ -159,7 +159,7 @@ public class RunList<J extends Job<J,R>, R extends Run<J,R>> extends ArrayList<R
* This also removes on-going builds, as RSS cannot be used to publish information
* if it changes.
*/
public RunList<J,R> newBuilds() {
public RunList<R> newBuilds() {
GregorianCalendar threshold = new GregorianCalendar();
threshold.add(Calendar.DAY_OF_YEAR,-7);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册