I have some classes that all implement the same Java interface, which essentially allows fetching SQLite ContentValues associated with the particular implementor, and these classes are grouped into lists in various classes throughout my application. I have been hoping to use generic list insert methods to handle any of these lists, ideally in the manner of:
public void doSomething(List<? implements Interface) {
...
}
Yet generics/interfaces do not function this way. Now, I could do:
public void doSomething(List<? extends SuperClass) {
...
}
If I made the class abstract (and set the default methods to throw RunTimeExceptions to force override by sub-classes) it would accomplish essentially the same thing, just much uglier.
This is not “mission critical” to anything I’m working on, I’m just curious if there are smoother ways to accomplish certain tasks.
with generics you use extends even for interfaces