I am Trying to write a generic method which accepts any type to List of Objects and then it checks for the type and downcast as per the type:
public Response generate(List<Object> objects){
    if(objects instanceof List<ClassA>){
        /*List<ClassA> classA =(List<ClassA>) (Object) objects;
        System.out.println(classA.lastIndexOf(classA));
        System.out.println("after downcasting");
*/      
        /*List<ClassA> customer = (List<ClassA>) objects.stream()
                .filter(ClassA.class::isInstance)
                .map(ClassA.class::cast)
                .collect(Collectors.toList());*/
        List<ClassA> classA=(List<ClassA>)(Object)objects;
        addDataToExcel(classA);
    }
    else if(objects instanceof ClassB){
        ClassB classb=(ClassB) objects;
    }
    else if(objects instanceof ClassC){
        ClassC classc=(ClassC) objects;
    }
    return response;
}
 
    