This works as intended - the (non static) inner class Node is parametrized with the Tree's params (K, V):
public class Tree<K,V> {
private abstract class Node extends Page<K,V> {}
private final class InnerNode extends Node {}
private final class LeafNode extends Node {}
}
Now I want to somehow convey to the compiler that the inner Nodes should accept only Integers as parameters. Tried:
private abstract class Node<V> extends Page<K, V> {}
but it displays the warning:
The type parameter V is hiding the type V
I want to achieve:
public class Tree<K, V> {
/** The type parameter V is hiding the type V */
private abstract class Node<V> extends Page<K, V> {}
private final class InnerNode extends Node<Integer> {}
private final class LeafNode<V> extends Node<V> {}
}
but with V being the Tree's type param. Below won't compile:
public class Tree<K, V> {
private abstract class Node<T extends V> extends Page<K, V> {}
/**
* Bound mismatch: The type Integer is not a valid substitute for the
* bounded parameter <T extends V> of the type Tree<K,V>.Node<T>
*/
private final class InnerNode extends Node<Integer> {}
private final class LeafNode<T extends V> extends Node<T> {}
}
Is what I want to do even possible ? Or a gross misunderstanding of generics ?