So, I want to have a List of types, then loop through the List and check if an Object is instance of the type in that list.
This is how I would imagine it to work, but that is no Java syntax. Type1.class also doesn't work
List<Object> types = new ArrayList();
types.add(Type1);
types.add(Type2);
for (Object type : types) {
if (someObject instanceof type) {
doSomething();
}
}
or the same thing with List<Class>
or something like that
this clearly doesn't work, but I dont know whats the best way to do it. Of course I could just hardcode every Object I want to check, but that doesn't seem that elegant.