Determine the type of a list in java

0
Hi all, this is a very simplified picture of my issue. please suppose the following: - i have the entity "vehicle" as generalizaion of the entity "car". - i have java action that takes a parameter "param" of type "vehicle"   In the java action, if i pass a "car" the "param.getMendixObject().getType()" gives me a "car". If i pass a "vehicle", i get "vehicle" That is just as expected.   My question now: My java action should take a "list of vehicle" as parameter. Can i somehow determine if it is a "list of vehicle" or a "list of car" in my java action? i haven't found anything regarding that. My current solution is to pass a "prototype object" which is either a "car" or a "vehicle" to get the needed type, but since this is ugly, i want to get rid of that prototype object.      
asked
1 answers
0

You can either test the first of the list

if (!vehiclelist.isEmpty()) {
	if (vehiclelist.get(0).getMendixObject().getType().equals(Car.getType())) {
		
	}
}

 

or all

vehiclelist.forEach(vehicle -> { 
	if (Vehicle.getType().equals(Car.getType())) {
	}
}
);

it is recommend to use the proxy instead of "Car" or "MyModule.Car"

answered