Extract Function: Type parameters inference

This commit is contained in:
Alexey Sedunov
2014-04-23 18:59:47 +04:00
parent 399c9c1175
commit 5fc1725b33
30 changed files with 469 additions and 17 deletions
@@ -125,17 +125,27 @@ public class DFS {
}
}
public static abstract class NodeHandlerWithListResult<N, R> extends AbstractNodeHandler<N, List<R>> {
public static abstract class CollectingNodeHandler<N, R, C extends Iterable<R>> extends AbstractNodeHandler<N, C> {
@NotNull
protected final LinkedList<R> result = new LinkedList<R>();
protected final C result;
protected CollectingNodeHandler(@NotNull C result) {
this.result = result;
}
@Override
@NotNull
public List<R> result() {
public C result() {
return result;
}
}
public static abstract class NodeHandlerWithListResult<N, R> extends CollectingNodeHandler<N, R, LinkedList<R>> {
protected NodeHandlerWithListResult() {
super(new LinkedList<R>());
}
}
public static class TopologicalOrder<N> extends NodeHandlerWithListResult<N, N> {
@Override
public void afterChildren(N current) {