Your pattern class has to extend BasicObject and extend/implement CodeObject (which is actually an interface). You can do it with multiple classes declared in the wildcard definition of the method signature, like this:
public <T extends BasicObject & CodeObject> void myMethod(Class<T> clazz)
Note that it won’t work if you do it any of these ways:
-
public <T extends BasicObject, CodeObject> void myMethod(Class<T> clazz)This is technically valid syntax, but
CodeObjectis unused; the method will accept any classes that extendsBasicObject, no matter whether they extend/implementCodeObject. -
public void myMethod(Class<? extends BasicObject & CodeObject> clazz)
public void myMethod(Class<? extends BasicObject, CodeObject> clazz)These are just wrong syntax according to Java.