How can you create a generic class/method that excepts generic types in a list of types? This is the pseudo code of what I want:
class Foo {
Object arrayOfTypes[] = {Integer, Double, Boolean};
public <T in arrayOfTypes> void Bar() {
...
}
}
So, T has to be either an Integer, Double, or Boolean. Also, the only classes that can be used are from a library, so I can't edit them to extend certain classes and do something like <T extends Car>
. Is there a way to do this?