Q:

How to dynamically define the Class that can be used as a parameter in a method?

I have a method that I use to validate a POJO in Spring MVC (this allows me to rely on the @Annotation in the POJO and at the same time validate the POJO programmatically whenever and wherever I want without using the annotation @Valid).
In need to pass the Class of the object to the method in order to validate: 
public void validate(Class clazz, Object model, BindingResult result){      
    ...         
    Set<ConstraintViolation<clazz>> constraintViolations=validator.validate((clazz)model);
        for (ConstraintViolation<clazz> constraintViolation : constraintViolations) {
...
}

My code is not correct, since a get the error:

clazz cannot be resolved to a type

How should I edit my code in order to be able to pass to this method any Class I want?
Thank you

A:

You can  generify the method 
public <T> void setList(Class<T> clazz){
  List<T> list = new ArrayList<>();
}

and call it as follows
setList(Person.class)

