I need to defined a Generic type as a subclass implementing an interface, like this (DOES NOT COMPILE):
public class Foo<T extends SomeClass implements SomeInterface> {
...
}
Is it possible to do something like this?
Jon Skeet, where are you when we need you 😉
That’s the syntax:
These are called Intersection Types. They don’t differentiate between classes and interfaces. Intersection types are also briefly mentioned in the Java tutorial on Bounded Type Parameters.